Source File
creds.go
Belonging Package
google.golang.org/api/internal
package internal
import (
)
func ( context.Context, *DialSettings) (*google.Credentials, error) {
, := baseCreds(, )
if != nil {
return nil,
}
if .ImpersonationConfig != nil {
return impersonateCredentials(, , )
}
return , nil
}
func ( context.Context, *DialSettings) (*google.Credentials, error) {
if .Credentials != nil {
return .Credentials, nil
}
if .CredentialsJSON != nil {
return credentialsFromJSON(, .CredentialsJSON, .Endpoint, .Scopes, .Audiences)
}
if .CredentialsFile != "" {
, := ioutil.ReadFile(.CredentialsFile)
if != nil {
return nil, fmt.Errorf("cannot read credentials file: %v", )
}
return credentialsFromJSON(, , .Endpoint, .Scopes, .Audiences)
}
if .TokenSource != nil {
return &google.Credentials{TokenSource: .TokenSource}, nil
}
, := google.FindDefaultCredentials(, .Scopes...)
if != nil {
return nil,
}
if len(.JSON) > 0 {
return credentialsFromJSON(, .JSON, .Endpoint, .Scopes, .Audiences)
return , nil
}
const (
serviceAccountKey = "service_account"
)
}
if := json.Unmarshal(.JSON, &); != nil {
return nil,
}
if . == serviceAccountKey {
, := selfSignedJWTTokenSource(, , )
if != nil {
return nil,
}
.TokenSource =
}
}
return ,
}
:=
func ( *google.Credentials) string {
var struct {
string `json:"quota_project_id"`
}
if := json.Unmarshal(.JSON, &); != nil {
return ""
}
return .
}
func ( context.Context, *google.Credentials, *DialSettings) (*google.Credentials, error) {
if len(.ImpersonationConfig.Scopes) == 0 {
.ImpersonationConfig.Scopes = .Scopes
}
, := impersonate.TokenSource(, .TokenSource, .ImpersonationConfig)
if != nil {
return nil,
}
return &google.Credentials{
TokenSource: ,
ProjectID: .ProjectID,
}, nil
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |