@@ -192,6 +192,12 @@ func (f *credentialsFile) tokenSource(ctx context.Context, params CredentialsPar
192
192
tok := & oauth2.Token {RefreshToken : f .RefreshToken }
193
193
return cfg .TokenSource (ctx , tok ), nil
194
194
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
+ }
195
201
cfg := & externalaccount.Config {
196
202
Audience : f .Audience ,
197
203
SubjectTokenType : f .SubjectTokenType ,
@@ -203,7 +209,7 @@ func (f *credentialsFile) tokenSource(ctx context.Context, params CredentialsPar
203
209
ClientID : f .ClientID ,
204
210
CredentialSource : & f .CredentialSource ,
205
211
QuotaProjectID : f .QuotaProjectID ,
206
- Scopes : params . Scopes ,
212
+ Scopes : scopes ,
207
213
WorkforcePoolUserProject : f .WorkforcePoolUserProject ,
208
214
}
209
215
return externalaccount .NewTokenSource (ctx , * cfg )
@@ -229,10 +235,14 @@ func (f *credentialsFile) tokenSource(ctx context.Context, params CredentialsPar
229
235
if err != nil {
230
236
return nil , err
231
237
}
238
+ scopes := params .Scopes
239
+ if len (scopes ) == 0 {
240
+ scopes = []string {"https://www.googleapis.com/auth/cloud-platform" }
241
+ }
232
242
imp := impersonate.ImpersonateTokenSource {
233
243
Ctx : ctx ,
234
244
URL : f .ServiceAccountImpersonationURL ,
235
- Scopes : params . Scopes ,
245
+ Scopes : scopes ,
236
246
Ts : ts ,
237
247
Delegates : f .Delegates ,
238
248
}
0 commit comments