Merge pull request from iamqizhao/master

Add application default credentials
This commit is contained in:
Qi Zhao
2015-04-15 17:28:28 -07:00

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