forked from Mirrors/oauth2
Managed VM users should depend on http.DefaultTransport by default.
This commit is contained in:
parent
6bb0a5207a
commit
32b45383ad
|
@ -12,8 +12,9 @@ import (
|
||||||
// AppEngineConfig represents a configuration for an
|
// AppEngineConfig represents a configuration for an
|
||||||
// App Engine application's Google service account.
|
// App Engine application's Google service account.
|
||||||
type AppEngineConfig struct {
|
type AppEngineConfig struct {
|
||||||
// Transport represents the default transport to be used while constructing
|
// Transport is the transport to be used
|
||||||
// oauth2.Transport instances from this configuration.
|
// to construct new oauth2.Transport instances from
|
||||||
|
// this configuration.
|
||||||
Transport *urlfetch.Transport
|
Transport *urlfetch.Transport
|
||||||
|
|
||||||
context appengine.Context
|
context appengine.Context
|
||||||
|
|
|
@ -3,33 +3,31 @@
|
||||||
package google
|
package google
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/golang/oauth2"
|
"github.com/golang/oauth2"
|
||||||
"google.golang.org/appengine"
|
"google.golang.org/appengine"
|
||||||
"google.golang.org/appengine/urlfetch"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// AppEngineConfig represents a configuration for an
|
// AppEngineConfig represents a configuration for an
|
||||||
// App Engine application's Google service account.
|
// App Engine application's Google service account.
|
||||||
type AppEngineConfig struct {
|
type AppEngineConfig struct {
|
||||||
// Transport represents the default transport to be used while constructing
|
// Transport is the round tripper to be used
|
||||||
// oauth2.Transport instances from this configuration.
|
// to construct new oauth2.Transport instances from
|
||||||
Transport *urlfetch.Transport
|
// this configuration.
|
||||||
context appengine.Context
|
Transport http.RoundTripper
|
||||||
|
|
||||||
scopes []string
|
context appengine.Context
|
||||||
|
scopes []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAppEngineConfig creates a new AppEngineConfig for the
|
// NewAppEngineConfig creates a new AppEngineConfig for the
|
||||||
// provided auth scopes.
|
// provided auth scopes.
|
||||||
func NewAppEngineConfig(context appengine.Context, scopes []string) *AppEngineConfig {
|
func NewAppEngineConfig(context appengine.Context, scopes []string) *AppEngineConfig {
|
||||||
return &AppEngineConfig{
|
return &AppEngineConfig{
|
||||||
Transport: &urlfetch.Transport{
|
Transport: http.DefaultTransport,
|
||||||
Context: context,
|
context: context,
|
||||||
Deadline: 0,
|
scopes: scopes,
|
||||||
AllowInvalidServerCertificate: false,
|
|
||||||
},
|
|
||||||
context: context,
|
|
||||||
scopes: scopes,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,12 +37,12 @@ type metaTokenRespBody struct {
|
||||||
// ComputeEngineConfig represents a OAuth 2.0 consumer client
|
// ComputeEngineConfig represents a OAuth 2.0 consumer client
|
||||||
// running on Google Compute Engine.
|
// running on Google Compute Engine.
|
||||||
type ComputeEngineConfig struct {
|
type ComputeEngineConfig struct {
|
||||||
// Client is the default HTTP client to be used while retrieving
|
// Client is the HTTP client to be used to retrieve
|
||||||
// tokens from the OAuth 2.0 provider.
|
// tokens from the OAuth 2.0 provider.
|
||||||
Client *http.Client
|
Client *http.Client
|
||||||
|
|
||||||
// Transport represents the default round tripper to be used
|
// Transport is the round tripper to be used
|
||||||
// while constructing new oauth2.Transport instances from
|
// to construct new oauth2.Transport instances from
|
||||||
// this configuration.
|
// this configuration.
|
||||||
Transport http.RoundTripper
|
Transport http.RoundTripper
|
||||||
|
|
||||||
|
|
6
jwt.go
6
jwt.go
|
@ -67,12 +67,12 @@ func NewJWTConfig(opts *JWTOptions, aud string) (*JWTConfig, error) {
|
||||||
// JWTConfig represents an OAuth 2.0 provider and client options to
|
// JWTConfig represents an OAuth 2.0 provider and client options to
|
||||||
// provide authorized transports with a Bearer JWT token.
|
// provide authorized transports with a Bearer JWT token.
|
||||||
type JWTConfig struct {
|
type JWTConfig struct {
|
||||||
// Client is the default HTTP client to be used while retrieving
|
// Client is the HTTP client to be used to retrieve
|
||||||
// tokens from the OAuth 2.0 provider.
|
// tokens from the OAuth 2.0 provider.
|
||||||
Client *http.Client
|
Client *http.Client
|
||||||
|
|
||||||
// Transport represents the default round tripper to be used
|
// Transport is the round tripper to be used
|
||||||
// while constructing new oauth2.Transport instances from
|
// to construct new oauth2.Transport instances from
|
||||||
// this configuration.
|
// this configuration.
|
||||||
Transport http.RoundTripper
|
Transport http.RoundTripper
|
||||||
|
|
||||||
|
|
|
@ -111,12 +111,12 @@ func NewConfig(opts *Options, authURL, tokenURL string) (*Config, error) {
|
||||||
|
|
||||||
// Config represents the configuration of an OAuth 2.0 consumer client.
|
// Config represents the configuration of an OAuth 2.0 consumer client.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
// Client is the default HTTP client to be used while retrieving
|
// Client is the HTTP client to be used to retrieve
|
||||||
// tokens from the OAuth 2.0 provider.
|
// tokens from the OAuth 2.0 provider.
|
||||||
Client *http.Client
|
Client *http.Client
|
||||||
|
|
||||||
// Transport represents the default round tripper to be used
|
// Transport is the round tripper to be used
|
||||||
// while constructing new oauth2.Transport instances from
|
// to construct new oauth2.Transport instances from
|
||||||
// this configuration.
|
// this configuration.
|
||||||
Transport http.RoundTripper
|
Transport http.RoundTripper
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue