{"modulePath":"github.com/readystackfree/cli","version":"v29.9.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package api\n\n## Variables\n\n```go\nvar ErrTimeout = errors.New(\"timed out waiting for device token\")\n```\n\n## Types\n\n```go\ntype API struct {\n\t// TenantURL is the base used for each request to Auth0.\n\tTenantURL string\n\t// ClientID is the client ID for the application to auth with the tenant.\n\tClientID string\n\t// Scopes are the scopes that are requested during the device auth flow.\n\tScopes []string\n}\n```\nAPI represents API interactions with Auth0.\n\n```go\nfunc (API) GetAutoPAT(ctx context.Context, audience string, res TokenResponse) (string, error)\n```\n\n```go\nfunc (a API) GetDeviceCode(ctx context.Context, audience string) (State, error)\n```\nGetDeviceCode 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.\n\n```go\nfunc (a API) RevokeToken(ctx context.Context, refreshToken string) error\n```\nRevokeToken revokes a refresh token with the tenant so that it can no longer be used to get new tokens.\n\n```go\nfunc (a API) WaitForDeviceToken(ctx context.Context, state State) (TokenResponse, error)\n```\nWaitForDeviceToken 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).\n\n```go\ntype OAuthAPI interface {\n\tGetDeviceCode(ctx context.Context, audience string) (State, error)\n\tWaitForDeviceToken(ctx context.Context, state State) (TokenResponse, error)\n\tRevokeToken(ctx context.Context, refreshToken string) error\n\tGetAutoPAT(ctx context.Context, audience string, res TokenResponse) (string, error)\n}\n```\n\n```go\ntype State struct {\n\tDeviceCode      string `json:\"device_code\"`\n\tUserCode        string `json:\"user_code\"`\n\tVerificationURI string `json:\"verification_uri_complete\"`\n\tExpiresIn       int    `json:\"expires_in\"`\n\tInterval        int    `json:\"interval\"`\n}\n```\nState represents the state of exchange after submitting.\n\n```go\nfunc (s State) ExpiryDuration() time.Duration\n```\nExpiryDuration returns the total duration for which the client should keep polling.\n\n```go\nfunc (s State) IntervalDuration() time.Duration\n```\nIntervalDuration returns the duration that should be waited between each auth polling event.\n\n```go\ntype TokenResponse struct {\n\tAccessToken      string  `json:\"access_token\"`\n\tIDToken          string  `json:\"id_token\"`\n\tRefreshToken     string  `json:\"refresh_token\"`\n\tScope            string  `json:\"scope\"`\n\tExpiresIn        int     `json:\"expires_in\"`\n\tTokenType        string  `json:\"token_type\"`\n\tError            *string `json:\"error,omitempty\"`\n\tErrorDescription string  `json:\"error_description,omitempty\"`\n}\n```\nTokenResponse represents the response of the /oauth/token route.\n\n","path":"github.com/readystackfree/cli/internal/oauth/api","name":"api","synopsis":"","isRedistributable":true}
