@@ -5,6 +5,7 @@ import type {ResolvedConfig, LoadConfigOptions, AuthMethod} from './config.js';
55import { OAuthStrategy } from '../auth/oauth.js' ;
66import { ImplicitOAuthStrategy } from '../auth/oauth-implicit.js' ;
77import { t } from '../i18n/index.js' ;
8+ import { DEFAULT_ACCOUNT_MANAGER_HOST } from '../defaults.js' ;
89
910/**
1011 * Base command for operations requiring OAuth authentication.
@@ -47,6 +48,12 @@ export abstract class OAuthCommand<T extends typeof Command> extends BaseCommand
4748 options : ALL_AUTH_METHODS ,
4849 helpGroup : 'AUTH' ,
4950 } ) ,
51+ 'account-manager-host' : Flags . string ( {
52+ description : 'Account Manager hostname for OAuth' ,
53+ env : 'SFCC_ACCOUNT_MANAGER_HOST' ,
54+ default : DEFAULT_ACCOUNT_MANAGER_HOST ,
55+ helpGroup : 'AUTH' ,
56+ } ) ,
5057 } ;
5158
5259 /**
@@ -96,6 +103,13 @@ export abstract class OAuthCommand<T extends typeof Command> extends BaseCommand
96103 return config ;
97104 }
98105
106+ /**
107+ * Gets the configured Account Manager host.
108+ */
109+ protected get accountManagerHost ( ) : string {
110+ return this . flags [ 'account-manager-host' ] ?? DEFAULT_ACCOUNT_MANAGER_HOST ;
111+ }
112+
99113 /**
100114 * Gets an OAuth auth strategy based on allowed auth methods and available credentials.
101115 *
@@ -106,6 +120,7 @@ export abstract class OAuthCommand<T extends typeof Command> extends BaseCommand
106120 */
107121 protected getOAuthStrategy ( ) : OAuthStrategy | ImplicitOAuthStrategy {
108122 const config = this . resolvedConfig ;
123+ const accountManagerHost = this . accountManagerHost ;
109124 // Default to client-credentials and implicit if no methods specified
110125 const allowedMethods = config . authMethods || ( [ 'client-credentials' , 'implicit' ] as AuthMethod [ ] ) ;
111126
@@ -117,6 +132,7 @@ export abstract class OAuthCommand<T extends typeof Command> extends BaseCommand
117132 clientId : config . clientId ,
118133 clientSecret : config . clientSecret ,
119134 scopes : config . scopes ,
135+ accountManagerHost,
120136 } ) ;
121137 }
122138 break ;
@@ -126,6 +142,7 @@ export abstract class OAuthCommand<T extends typeof Command> extends BaseCommand
126142 return new ImplicitOAuthStrategy ( {
127143 clientId : config . clientId ,
128144 scopes : config . scopes ,
145+ accountManagerHost,
129146 } ) ;
130147 }
131148 break ;
0 commit comments