NewDefaultCredentialsWithOptions returns a credentials bundle that is configured to work with google services. This API is experimental.
(opts DefaultCredentialsOptions)
| 48 | // |
| 49 | // This API is experimental. |
| 50 | func 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. |