Documentation ¶
Index ¶
- Variables
- type API
- func (a API) GetAutoPAT(ctx context.Context, audience string, res TokenResponse) (string, error)
- func (a API) GetDeviceCode(ctx context.Context, audience string) (State, error)
- func (a API) RevokeToken(ctx context.Context, refreshToken string) error
- func (a API) WaitForDeviceToken(ctx context.Context, state State) (TokenResponse, error)
- type OAuthAPI
- type State
- type TokenResponse
Constants ¶
This section is empty.
Variables ¶
var ErrTimeout = errors.New("timed out waiting for device token")
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { // TenantURL is the base used for each request to Auth0. TenantURL string // ClientID is the client ID for the application to auth with the tenant. ClientID string // Scopes are the scopes that are requested during the device auth flow. Scopes []string }
API represents API interactions with Auth0.
func (API) GetAutoPAT ¶
func (API) GetDeviceCode ¶
GetDeviceCode initiates the device-code auth flow with the tenant. The state returned contains the device code that the user must use to authenticate, as well as the URL to visit, etc.
func (API) RevokeToken ¶
RevokeToken revokes a refresh token with the tenant so that it can no longer be used to get new tokens.
func (API) WaitForDeviceToken ¶
WaitForDeviceToken polls the tenant to get access/refresh tokens for the user. This should be called after GetDeviceCode, and will block until the user has authenticated or we have reached the time limit for authenticating (based on the response from GetDeviceCode).
type OAuthAPI ¶
type OAuthAPI interface { GetDeviceCode(ctx context.Context, audience string) (State, error) WaitForDeviceToken(ctx context.Context, state State) (TokenResponse, error) RevokeToken(ctx context.Context, refreshToken string) error GetAutoPAT(ctx context.Context, audience string, res TokenResponse) (string, error) }
type State ¶
type State struct { DeviceCode string `json:"device_code"` UserCode string `json:"user_code"` VerificationURI string `json:"verification_uri_complete"` ExpiresIn int `json:"expires_in"` Interval int `json:"interval"` }
State represents the state of exchange after submitting.
func (State) ExpiryDuration ¶
ExpiryDuration returns the total duration for which the client should keep polling.
func (State) IntervalDuration ¶
IntervalDuration returns the duration that should be waited between each auth polling event.
type TokenResponse ¶
type TokenResponse struct { AccessToken string `json:"access_token"` IDToken string `json:"id_token"` RefreshToken string `json:"refresh_token"` Scope string `json:"scope"` ExpiresIn int `json:"expires_in"` TokenType string `json:"token_type"` Error *string `json:"error,omitempty"` ErrorDescription string `json:"error_description,omitempty"` }
TokenResponse represents the response of the /oauth/token route.