XaiProvider
Namespace: E2E.OAuth
public sealed class XaiProvider : IOAuthProviderSuperGrok and X Premium+ through SpaceXAI’s OAuth server: RFC 8628 device authorization for the Grok CLI’s public client. The token is a plain bearer against the ordinary SpaceXAI API. Refresh tokens rotate.
Inheritance: object
Implements: IOAuthProvider
Constructors
Section titled “Constructors”XaiProvider(HttpClient?, string, string, string)
Section titled “XaiProvider(HttpClient?, string, string, string)”public XaiProvider(HttpClient? http = null, string referrer = "e2e", string issuer = "https://auth.x.ai", string modelsUrl = "https://api.x.ai/v1/language-models")Parameters
| Name | Type | Description |
|---|---|---|
http |
HttpClient | Sends the login’s own requests. Unset, a shared client. |
referrer |
string | The referrer the device request names: your product. |
issuer |
string | Test seam. |
modelsUrl |
string | Test seam. |
Fields
Section titled “Fields”ApiUrl
Section titled “ApiUrl”public const string ApiUrl = "https://api.x.ai/v1"Value: string
Properties
Section titled “Properties”public string Id { get; }The id in the credentials file and on the command line: openai, github-copilot, opencode-console, spacexai.
Value: string
public string Name { get; }The vendor’s name for messages.
Value: string
Methods
Section titled “Methods”ListModelsAsync(HttpClient, CancellationToken)
Section titled “ListModelsAsync(HttpClient, CancellationToken)”public Task<IReadOnlyList<SubscriptionModel>> ListModelsAsync(HttpClient http, CancellationToken cancellationToken)The language models the token reaches; aliases are listed with their target.
Parameters
| Name | Type | Description |
|---|---|---|
http |
HttpClient | |
cancellationToken |
CancellationToken |
Returns: Task<IReadOnlyList<SubscriptionModel>>
LoginAsync(OAuthLoginCallbacks, OAuthLoginOptions, CancellationToken)
Section titled “LoginAsync(OAuthLoginCallbacks, OAuthLoginOptions, CancellationToken)”public Task<OAuthCredentials> LoginAsync(OAuthLoginCallbacks callbacks, OAuthLoginOptions options, CancellationToken cancellationToken)Parameters
| Name | Type | Description |
|---|---|---|
callbacks |
OAuthLoginCallbacks | |
options |
OAuthLoginOptions | |
cancellationToken |
CancellationToken |
Returns: Task<OAuthCredentials>
PrepareAsync(HttpRequestMessage, OAuthCredentials, CancellationToken)
Section titled “PrepareAsync(HttpRequestMessage, OAuthCredentials, CancellationToken)”public Task PrepareAsync(HttpRequestMessage request, OAuthCredentials credentials, CancellationToken cancellationToken)Adjusts one API request before it goes out. It arrives with the bearer token and the user agent set; the provider rewrites the URL, adds vendor headers, or changes the body.
Parameters
| Name | Type | Description |
|---|---|---|
request |
HttpRequestMessage | |
credentials |
OAuthCredentials | |
cancellationToken |
CancellationToken |
Returns: Task
RefreshAsync(OAuthCredentials, CancellationToken)
Section titled “RefreshAsync(OAuthCredentials, CancellationToken)”public Task<OAuthCredentials> RefreshAsync(OAuthCredentials credentials, CancellationToken cancellationToken)Renews the credentials, or throws LoginRequired when the user has to sign in again.
Parameters
| Name | Type | Description |
|---|---|---|
credentials |
OAuthCredentials | |
cancellationToken |
CancellationToken |
Returns: Task<OAuthCredentials>