@@ -192,6 +192,12 @@ func (f *credentialsFile) tokenSource(ctx context.Context, params CredentialsPar
192192 tok := & oauth2.Token {RefreshToken : f .RefreshToken }
193193 return cfg .TokenSource (ctx , tok ), nil
194194 case externalAccountKey :
195+ scopes := params .Scopes
196+ if f .ServiceAccountImpersonationURL != "" {
197+ if len (scopes ) == 0 {
198+ scopes = []string {"https://www.googleapis.com/auth/cloud-platform" }
199+ }
200+ }
195201 cfg := & externalaccount.Config {
196202 Audience : f .Audience ,
197203 SubjectTokenType : f .SubjectTokenType ,
@@ -203,7 +209,7 @@ func (f *credentialsFile) tokenSource(ctx context.Context, params CredentialsPar
203209 ClientID : f .ClientID ,
204210 CredentialSource : & f .CredentialSource ,
205211 QuotaProjectID : f .QuotaProjectID ,
206- Scopes : params . Scopes ,
212+ Scopes : scopes ,
207213 WorkforcePoolUserProject : f .WorkforcePoolUserProject ,
208214 }
209215 return externalaccount .NewTokenSource (ctx , * cfg )
@@ -229,10 +235,14 @@ func (f *credentialsFile) tokenSource(ctx context.Context, params CredentialsPar
229235 if err != nil {
230236 return nil , err
231237 }
238+ scopes := params .Scopes
239+ if len (scopes ) == 0 {
240+ scopes = []string {"https://www.googleapis.com/auth/cloud-platform" }
241+ }
232242 imp := impersonate.ImpersonateTokenSource {
233243 Ctx : ctx ,
234244 URL : f .ServiceAccountImpersonationURL ,
235- Scopes : params . Scopes ,
245+ Scopes : scopes ,
236246 Ts : ts ,
237247 Delegates : f .Delegates ,
238248 }
0 commit comments