MCPcopy
hub / github.com/grpc/grpc-go / NewDefaultCredentialsWithOptions

Function NewDefaultCredentialsWithOptions

credentials/google/google.go:50–73  ·  view source on GitHub ↗

NewDefaultCredentialsWithOptions returns a credentials bundle that is configured to work with google services. This API is experimental.

(opts DefaultCredentialsOptions)

Source from the content-addressed store, hash-verified

48//
49// This API is experimental.
50func NewDefaultCredentialsWithOptions(opts DefaultCredentialsOptions) credentials.Bundle {
51 if opts.PerRPCCreds == nil {
52 var err error
53 // If the ADC ends up being Compute Engine Credentials, this context
54 // won't be used. Otherwise, the context dictates all the subsequent
55 // token requests via HTTP. So we cannot have any deadline or timeout.
56 opts.PerRPCCreds, err = newADC(context.TODO())
57 if err != nil {
58 logger.Warningf("NewDefaultCredentialsWithOptions: failed to create application oauth: %v", err)
59 }
60 }
61 if opts.ALTSPerRPCCreds != nil {
62 opts.PerRPCCreds = &dualPerRPCCreds{
63 perRPCCreds: opts.PerRPCCreds,
64 altsPerRPCCreds: opts.ALTSPerRPCCreds,
65 }
66 }
67 c := &creds{opts: opts}
68 bundle, err := c.NewWithMode(internal.CredsBundleModeFallback)
69 if err != nil {
70 logger.Warningf("NewDefaultCredentialsWithOptions: failed to create new creds: %v", err)
71 }
72 return bundle
73}
74
75// NewDefaultCredentials returns a credentials bundle that is configured to work
76// with google services.

Calls 2

NewWithModeMethod · 0.95
WarningfMethod · 0.65