Skip to content

google: Add DelegateTokenSource #336

Closed
@salrashid123

Description

@salrashid123

Delegate Credentials is basically a way for a user or (more common) service account to impersonate another service account.

DelegateTokenSource allows a TokenSource issued to a user or
service account to impersonate another. The target service account
must grant the orginating principal the "Service Account Token Creator" IAM role:

https://cloud.google.com/iam/docs/service-accounts#the_service_account_token_creator_role

suggested usage

principal := "[email protected]"
lifetime := 30 * time.Second
delegates := []string{}
newScopes := []string{storage.ScopeReadOnly}

rootTokenSource, _ := google.DefaultTokenSource(ctx, "https://www.googleapis.com/auth/iam")
delegatetokenSource, _ := google.DelegateTokenSource(ctx, rootTokenSource, principal, lifetime, delegates, newScopes)

storeageClient, _ = storage.NewClient(ctx, option.WithTokenSource(delegatetokenSource))
itrs := storeageClient.Buckets(ctx, "your_projct")

Ref:

--

 googleapis/google-cloud-common#266

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions