Skip to content

Commit cff29b9

Browse files
author
Senthil Kumar Karuppiah
committed
feat(idtoken): add support for external_account.
* Also fix a bug for impersonated_service_account * When creds are passed with WithCredentialsFile(), it doesn't work. * Pass the option when creating the token source. * Fixes PR googleapis#1879
1 parent 63c48a6 commit cff29b9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

idtoken/idtoken.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const (
3434
unknownCredType credentialsType = iota
3535
serviceAccount
3636
impersonatedServiceAccount
37+
external_account
3738
)
3839

3940
// NewClient creates a HTTP Client that automatically adds an ID token to each
@@ -139,7 +140,7 @@ func tokenSourceFromBytes(ctx context.Context, data []byte, audience string, ds
139140
return nil, err
140141
}
141142
return oauth2.ReuseTokenSource(tok, ts), nil
142-
case impersonatedServiceAccount:
143+
case impersonatedServiceAccount, external_account:
143144
type url struct {
144145
ServiceAccountImpersonationURL string `json:"service_account_impersonation_url"`
145146
}
@@ -155,7 +156,7 @@ func tokenSourceFromBytes(ctx context.Context, data []byte, audience string, ds
155156
TargetPrincipal: account,
156157
IncludeEmail: true,
157158
}
158-
ts, err := impersonate.IDTokenSource(ctx, config)
159+
ts, err := impersonate.IDTokenSource(ctx, config, option.WithCredentialsJSON(data))
159160
if err != nil {
160161
return nil, err
161162
}
@@ -188,6 +189,8 @@ func parseCredType(typeString string) credentialsType {
188189
return serviceAccount
189190
case "impersonated_service_account":
190191
return impersonatedServiceAccount
192+
case "external_account":
193+
return external_account
191194
default:
192195
return unknownCredType
193196
}

0 commit comments

Comments
 (0)