package internal
Import Path
golang.org/x/oauth2/internal (on go.dev)
Dependency Relation
imports 17 packages, and imported by one package
Involved Source Files
Package internal contains support packages for [golang.org/x/oauth2].
oauth2.go
token.go
transport.go
Package-Level Type Names (total 6)
AuthStyle is a copy of the golang.org/x/oauth2 package's AuthStyle type.
func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string, v url.Values, authStyle AuthStyle, styleCache *AuthStyleCache) (*Token, error)
const AuthStyleInHeader
const AuthStyleInParams
const AuthStyleUnknown
AuthStyleCache is the set of tokenURLs we've successfully used via
RetrieveToken and which style auth we ended up using.
It's called a cache, but it doesn't (yet?) shrink. It's expected that
the set of OAuth2 servers a program contacts over time is fixed and
small.
func (*LazyAuthStyleCache).Get() *AuthStyleCache
func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string, v url.Values, authStyle AuthStyle, styleCache *AuthStyleCache) (*Token, error)
ContextKey is just an empty struct. It exists so HTTPClient can be
an immutable public variable with a unique type. It's immutable
because nobody else can create a ContextKey, being unexported.
var HTTPClient
var golang.org/x/oauth2.HTTPClient
LazyAuthStyleCache is a backwards compatibility compromise to let Configs
have a lazily-initialized AuthStyleCache.
The two users of this, oauth2.Config and oauth2/clientcredentials.Config,
both would ideally just embed an unexported AuthStyleCache but because both
were historically allowed to be copied by value we can't retroactively add an
uncopyable Mutex to them.
We could use an atomic.Pointer, but that was added recently enough (in Go
1.18) that we'd break Go 1.17 users where the tests as of 2023-08-03
still pass. By using an atomic.Value, it supports both Go 1.17 and
copying by value, even if that's not ideal.
(*LazyAuthStyleCache) Get() *AuthStyleCache
mirrors oauth2.RetrieveError
Body []byte
ErrorCode string
ErrorDescription string
ErrorURI string
Response *http.Response
(*RetrieveError) Error() string
*RetrieveError : error
Token represents the credentials used to authorize
the requests to access protected resources on the OAuth 2.0
provider's backend.
This type is a mirror of [golang.org/x/oauth2.Token] and exists to break
an otherwise-circular dependency. Other internal packages
should convert this Token into an [golang.org/x/oauth2.Token] before use.
AccessToken is the token that authorizes and authenticates
the requests.
ExpiresIn is the OAuth2 wire format "expires_in" field,
which specifies how many seconds later the token expires,
relative to an unknown time base approximately around "now".
It is the application's responsibility to populate
`Expiry` from `ExpiresIn` when required.
Expiry is the optional expiration time of the access token.
If zero, TokenSource implementations will reuse the same
token forever and RefreshToken or equivalent
mechanisms for that TokenSource will not be used.
Raw optionally contains extra metadata from the server
when updating a token.
RefreshToken is a token that's used by the application
(as opposed to the user) to refresh the access token
if it expires.
TokenType is the type of token.
The Type method returns either this or "Bearer", the default.
func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string, v url.Values, authStyle AuthStyle, styleCache *AuthStyleCache) (*Token, error)
Package-Level Functions (total 3)
func ContextClient(ctx context.Context) *http.Client
ParseKey converts the binary contents of a private key file
to an [*rsa.PrivateKey]. It detects whether the private key is in a
PEM container or not. If so, it extracts the private key
from PEM container before conversion. It only supports PEM
containers with no passphrase.
func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string, v url.Values, authStyle AuthStyle, styleCache *AuthStyleCache) (*Token, error)
Package-Level Variables (only one)
HTTPClient is the context key to use with [context.WithValue]
to associate an [*http.Client] value with a context.
Package-Level Constants (total 3)
const AuthStyleInHeader AuthStyle = 2 const AuthStyleInParams AuthStyle = 1 const AuthStyleUnknown AuthStyle = 0![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux 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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |