mirror of https://github.com/grpc/grpc-go.git
Add application default credentials
This commit is contained in:
parent
d52d8e2d40
commit
94a47542e0
|
@ -215,3 +215,13 @@ func NewServiceAccountFromFile(keyFile string, scope ...string) (Credentials, er
|
|||
}
|
||||
return NewServiceAccountFromKey(jsonKey, scope...)
|
||||
}
|
||||
|
||||
// NewApplicationDefault returns "Application Default Credentials". For more
|
||||
// detail, see https://developers.google.com/accounts/docs/application-default-credentials.
|
||||
func NewApplicationDefault(ctx context.Context, scope ...string) (Credentials, error) {
|
||||
t, err := google.DefaultTokenSource(ctx, scope...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return TokenSource{t}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue