Add application default credentials

This commit is contained in:
iamqizhao 2015-04-15 17:24:37 -07:00
parent d52d8e2d40
commit 94a47542e0
1 changed files with 10 additions and 0 deletions

View File

@ -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
}