@@ -2,19 +2,18 @@ import {Command, Flags} from '@oclif/core';
22import { BaseCommand } from './base-command.js' ;
33import { loadConfig } from './config.js' ;
44import type { ResolvedConfig , LoadConfigOptions } from './config.js' ;
5- import type { AuthStrategy } from '../auth/types.js' ;
65import { OAuthStrategy } from '../auth/oauth.js' ;
76import { t } from '../i18n/index.js' ;
87
98/**
109 * Base command for operations requiring OAuth authentication.
11- * Use this for platform-level operations like ODS/Sandbox API .
10+ * Use this for platform-level operations like ODS, APIs .
1211 *
1312 * Environment variables:
1413 * - SFCC_CLIENT_ID: OAuth client ID
1514 * - SFCC_CLIENT_SECRET: OAuth client secret
1615 *
17- * For B2C instance operations, use InstanceCommand instead.
16+ * For B2C instance specific operations, use InstanceCommand instead.
1817 */
1918export abstract class OAuthCommand < T extends typeof Command > extends BaseCommand < T > {
2019 static baseFlags = {
@@ -29,6 +28,12 @@ export abstract class OAuthCommand<T extends typeof Command> extends BaseCommand
2928 env : 'SFCC_CLIENT_SECRET' ,
3029 helpGroup : 'AUTH' ,
3130 } ) ,
31+ scope : Flags . string ( {
32+ description : 'OAuth scopes to request (can be specified multiple times)' ,
33+ env : 'SFCC_OAUTH_SCOPES' ,
34+ multiple : true ,
35+ helpGroup : 'AUTH' ,
36+ } ) ,
3237 } ;
3338
3439 protected override loadConfiguration ( ) : ResolvedConfig {
@@ -42,13 +47,20 @@ export abstract class OAuthCommand<T extends typeof Command> extends BaseCommand
4247 clientSecret : this . flags [ 'client-secret' ] ,
4348 } ;
4449
45- return loadConfig ( flagConfig , options ) ;
50+ const config = loadConfig ( flagConfig , options ) ;
51+
52+ // Merge scopes from flags with config file scopes (flags take precedence if provided)
53+ if ( this . flags . scope && this . flags . scope . length > 0 ) {
54+ config . scopes = this . flags . scope ;
55+ }
56+
57+ return config ;
4658 }
4759
4860 /**
4961 * Gets an OAuth auth strategy.
5062 */
51- protected getOAuthStrategy ( ) : AuthStrategy {
63+ protected getOAuthStrategy ( ) : OAuthStrategy {
5264 const config = this . resolvedConfig ;
5365
5466 if ( config . clientId && config . clientSecret ) {
0 commit comments