Class: Ask::Auth::Providers::Xai

Inherits:
DeviceOAuth show all
Defined in:
lib/ask/auth/providers/xai.rb

Overview

xAI (Grok) device OAuth — "bring your xAI account": the public Grok-CLI OAuth client (RFC 8628 device grant against auth.x.ai/oauth2). Constants mirror opencode's xai.ts. The access token works as the bearer key for the standard xAI OpenAI-compatible API (api.x.ai/v1).

Constant Summary collapse

CLIENT_ID =
"b1a00492-073a-47ea-816f-4c329264a828"
TOKEN_URL =
"https://auth.x.ai/oauth2/token"
DEVICE_AUTHORIZATION_URL =
"https://auth.x.ai/oauth2/device/code"
SCOPE =
"openid profile email offline_access grok-cli:access api:access"

Constants inherited from DeviceOAuth

DeviceOAuth::DEVICE_CODE_GRANT_TYPE

Instance Attribute Summary

Attributes inherited from OAuth

#client_id, #redirect_uri

Instance Method Summary collapse

Methods inherited from DeviceOAuth

#complete_device_flow, #start_device_flow

Methods inherited from OAuth

#authorize!, #authorize_url, #call, #generate_code_challenge, #generate_code_verifier, #refresh

Constructor Details

#initialize(storage: nil, client_id: CLIENT_ID, http: Ask::Auth::OAuth::HTTP) ⇒ Xai

Returns a new instance of Xai.



19
20
21
22
# File 'lib/ask/auth/providers/xai.rb', line 19

def initialize(storage: nil, client_id: CLIENT_ID, http: Ask::Auth::OAuth::HTTP)
  super(storage: storage, client_id: client_id, token_url: TOKEN_URL,
    device_code_url: DEVICE_AUTHORIZATION_URL, scope: SCOPE, http: http)
end