hyper

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package hyper provides functions to handle Hyper device flow authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExchangeToken

func ExchangeToken(ctx context.Context, refreshToken string) (*oauth.Token, error)

ExchangeToken exchanges a refresh token for an access token.

func PollForToken

func PollForToken(ctx context.Context, deviceCode string, expiresIn int) (string, error)

PollForToken polls the /device/token endpoint until authorization is complete. It respects the polling interval and handles various error states.

Types

type DeviceAuthResponse

type DeviceAuthResponse struct {
	DeviceCode      string `json:"device_code"`
	UserCode        string `json:"user_code"`
	VerificationURL string `json:"verification_url"`
	ExpiresIn       int    `json:"expires_in"`
}

DeviceAuthResponse contains the response from the device authorization endpoint.

func InitiateDeviceAuth

func InitiateDeviceAuth(ctx context.Context) (*DeviceAuthResponse, error)

InitiateDeviceAuth calls the /device/auth endpoint to start the device flow.

type IntrospectTokenResponse

type IntrospectTokenResponse struct {
	Active bool   `json:"active"`
	Sub    string `json:"sub,omitempty"`
	OrgID  string `json:"org_id,omitempty"`
	Exp    int64  `json:"exp,omitempty"`
	Iat    int64  `json:"iat,omitempty"`
	Iss    string `json:"iss,omitempty"`
	Jti    string `json:"jti,omitempty"`
}

IntrospectTokenResponse contains the response from the token introspection endpoint.

func IntrospectToken

func IntrospectToken(ctx context.Context, accessToken string) (*IntrospectTokenResponse, error)

IntrospectToken validates an access token using the introspection endpoint. Implements OAuth2 Token Introspection (RFC 7662).

type TokenResponse

type TokenResponse struct {
	RefreshToken     string `json:"refresh_token,omitempty"`
	UserID           string `json:"user_id"`
	OrganizationID   string `json:"organization_id"`
	OrganizationName string `json:"organization_name"`
	Error            string `json:"error,omitempty"`
	ErrorDescription string `json:"error_description,omitempty"`
}

TokenResponse contains the response from the polling endpoint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL