@@ -242,13 +242,15 @@ export class NodeDynamicAuthProvider extends DynamicAuthProvider {
242
242
const codeChallenge = await this . generateCodeChallenge ( codeVerifier ) ;
243
243
244
244
// Prepare the authorization request URL
245
- const scopeString = scopes . join ( ' ' ) ;
246
245
const authorizationUrl = new URL ( this . _serverMetadata . authorization_endpoint ! ) ;
247
246
authorizationUrl . searchParams . append ( 'client_id' , this . clientId ) ;
248
247
authorizationUrl . searchParams . append ( 'response_type' , 'code' ) ;
249
- authorizationUrl . searchParams . append ( 'scope' , scopeString ) ;
250
248
authorizationUrl . searchParams . append ( 'code_challenge' , codeChallenge ) ;
251
249
authorizationUrl . searchParams . append ( 'code_challenge_method' , 'S256' ) ;
250
+ const scopeString = scopes . join ( ' ' ) ;
251
+ if ( scopeString ) {
252
+ authorizationUrl . searchParams . append ( 'scope' , scopeString ) ;
253
+ }
252
254
if ( this . _resourceMetadata ?. resource ) {
253
255
// If a resource is specified, include it in the request
254
256
authorizationUrl . searchParams . append ( 'resource' , this . _resourceMetadata . resource ) ;
@@ -321,7 +323,13 @@ export class NodeDynamicAuthProvider extends DynamicAuthProvider {
321
323
// Step 1: Request device and user codes
322
324
const deviceCodeRequest = new URLSearchParams ( ) ;
323
325
deviceCodeRequest . append ( 'client_id' , this . clientId ) ;
324
- deviceCodeRequest . append ( 'scope' , scopeString ) ;
326
+ if ( scopeString ) {
327
+ deviceCodeRequest . append ( 'scope' , scopeString ) ;
328
+ }
329
+ if ( this . _resourceMetadata ?. resource ) {
330
+ // If a resource is specified, include it in the request
331
+ deviceCodeRequest . append ( 'resource' , this . _resourceMetadata . resource ) ;
332
+ }
325
333
326
334
let deviceCodeResponse : Response ;
327
335
try {
0 commit comments