fix: Add delegates support

Get the delegates from the input JSON and use them in the refreshToken requests.

Updates #515
This commit is contained in:
guillaume blaquiere
2021-09-04 21:11:51 +02:00
parent 2fca3adf8d
commit c2f6109f1c
2 changed files with 11 additions and 7 deletions

View File

@@ -122,6 +122,7 @@ type credentialsFile struct {
TokenURLExternal string `json:"token_url"`
TokenInfoURL string `json:"token_info_url"`
ServiceAccountImpersonationURL string `json:"service_account_impersonation_url"`
Delegates []string `json:"delegates"`
CredentialSource externalaccount.CredentialSource `json:"credential_source"`
QuotaProjectID string `json:"quota_project_id"`
@@ -192,11 +193,11 @@ func (f *credentialsFile) tokenSource(ctx context.Context, params CredentialsPar
return nil, err
}
imp := externalaccount.ImpersonateTokenSource{
Ctx: ctx,
Url: f.ServiceAccountImpersonationURL,
Scopes: params.Scopes,
Ts: oauth2.ReuseTokenSource(nil, sourceToken),
// Delegates?? -> I don't know how to manage and how to use them here
Ctx: ctx,
Url: f.ServiceAccountImpersonationURL,
Scopes: params.Scopes,
Ts: oauth2.ReuseTokenSource(nil, sourceToken),
Delegates: f.Delegates,
}
return oauth2.ReuseTokenSource(nil, imp), nil
case "":