Skip to content

Hyper API

OAuth2 Device Flow implementation for Hyper service.

Functions

InitiateDeviceFlow / initiate_device_flow

Initiates the device authorization flow for Hyper.

Returns: Device code response

func InitiateDeviceFlow(ctx context.Context) (*DeviceCodeResponse, error)
async def initiate_device_flow() -> DeviceCode
async function initiateDeviceFlow(): Promise<DeviceCode>

PollForToken / poll_for_token

Polls for access token after user authorization.

Parameters: - device_code: Device code from initiation - on_success: Optional callback on successful authentication

Returns: Access token

func PollForToken(ctx context.Context, deviceCode *DeviceCodeResponse, 
                  onSuccess func(*Token)) (*Token, error)
async def poll_for_token(device_code: DeviceCode, 
                        on_success: Optional[Callable] = None) -> Token
async function pollForToken(deviceCode: DeviceCode, 
                           onSuccess?: (token: Token) => void): Promise<Token>

IntrospectToken / introspect_token

Introspects an access token to check its validity (RFC 7662).

Parameters: - token: Access token to introspect

Returns: Token introspection response

func IntrospectToken(ctx context.Context, token string) (map[string]interface{}, error)
async def introspect_token(token: str) -> dict
async function introspectToken(token: string): Promise<IntrospectionResponse>

Response Fields: - active (bool): Token validity status - scope (string): Token scope - exp (int): Expiration timestamp - iat (int): Issued at timestamp

Example:

info, err := hyper.IntrospectToken(ctx, token.AccessToken)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Active: %v\n", info["active"])
info = await introspect_token(token.access_token)
print(f"Active: {info['active']}")
const info = await introspectToken(token.accessToken);
console.log(`Active: ${info.active}`);

BaseURL / base_url

Returns the configured Hyper API base URL.

Default: https://api.hyper.io

Environment Variable: HYPER_BASE_URL

func BaseURL() string
def base_url() -> str
function baseURL(): string

Example:

export HYPER_BASE_URL="https://custom.hyper.io"

Endpoints

Endpoint Purpose
/oauth/device Device code initiation
/oauth/token Token exchange
/oauth/introspect Token introspection

Configuration

Custom Base URL

Configure via environment variable:

export HYPER_BASE_URL="https://your-hyper-instance.com"
$env:HYPER_BASE_URL = "https://your-hyper-instance.com"
os.Setenv("HYPER_BASE_URL", "https://your-hyper-instance.com")

Error Handling

Common errors:

  • invalid_token: Token is invalid or expired
  • connection_error: Cannot reach Hyper service
  • timeout: Request exceeded 30 second limit