Source File
default.go
Belonging Package
golang.org/x/oauth2/google
package google
import (
)
type Credentials struct {
ProjectID string // may be empty
TokenSource oauth2.TokenSource
type DefaultCredentials = Credentials
func ( context.Context, ...string) (oauth2.TokenSource, error) {
, := FindDefaultCredentials(, ...)
if != nil {
return nil,
}
return .TokenSource, nil
}
:= wellKnownFile()
if , := readCredentialsFile(, , ); == nil {
return , nil
} else if !os.IsNotExist() {
return nil, fmt.Errorf("google: error getting credentials using well-known file (%v): %v", , )
}
if appengineTokenFunc != nil {
return &DefaultCredentials{
ProjectID: appengineAppIDFunc(),
TokenSource: AppEngineTokenSource(, ...),
}, nil
}
if metadata.OnGCE() {
, := metadata.ProjectID()
return &DefaultCredentials{
ProjectID: ,
TokenSource: ComputeTokenSource("", ...),
}, nil
}
func ( context.Context, []byte, ...string) (*Credentials, error) {
var credentialsFile
if := json.Unmarshal(, &); != nil {
return nil,
}
, := .tokenSource(, append([]string(nil), ...))
if != nil {
return nil,
}
return &DefaultCredentials{
ProjectID: .ProjectID,
TokenSource: ,
JSON: ,
}, nil
}
func () string {
const = "application_default_credentials.json"
if runtime.GOOS == "windows" {
return filepath.Join(os.Getenv("APPDATA"), "gcloud", )
}
return filepath.Join(guessUnixHomeDir(), ".config", "gcloud", )
}
func ( context.Context, string, []string) (*DefaultCredentials, error) {
, := ioutil.ReadFile()
if != nil {
return nil,
}
return CredentialsFromJSON(, , ...)
![]() |
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. |