Documentation ¶
Overview ¶
Package oauth2x contains helpers for the oauth2 package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equals ¶
Equals checks that two tokens are equal by the following rules:
- AccessToken, TokenType, and RefreshToken must be identical. - Expiry must match within one second.
func NewOnNew ¶
func NewOnNew(ts oauth2.TokenSource, onNew func(*oauth2.Token, error)) oauth2.TokenSource
NewOnNew creates a token source which calls onNew when a new token is created, passing the new token and an error (if any occurred while fetching it). If onNew is nil, then the token source returned is equivalent to one returned by oauth2.ReuseTokenSource.
onNew is called synchronously under lock and will block other uses of this token source. If a non-blocking operation is desired, create a new goroutine in onNew.
func NewOnNewWithToken ¶
func NewOnNewWithToken(ts oauth2.TokenSource, onNew func(*oauth2.Token, error), tok *oauth2.Token) oauth2.TokenSource
NewOnNewWithToken is the same as OnNew, but uses tok as the first token instead of calling out to the wrapped token source first. If this token is no longer valid, then the wrapped token source will be called, as would be done for any expiry.
Types ¶
type TokenSource ¶
type TokenSource = oauth2.TokenSource