OpenCodeConsoleProvider
Namespace: E2E.OAuth
public sealed class OpenCodeConsoleProvider : IOAuthProviderOpenCode Zen and Go through an OpenCode Console sign-in. Console speaks RFC 8628 device authorization;
approving the code binds the login to one workspace, and its token is a bearer for both the Console API and
inference. Refresh tokens rotate. The workspace config says which models are served and over which protocol:
Zen is its opencode provider, Go opencode-go. Go ids take a go/ prefix here.
Inheritance: object
Implements: IOAuthProvider
Constructors
Section titled “Constructors”OpenCodeConsoleProvider(HttpClient?, string)
Section titled “OpenCodeConsoleProvider(HttpClient?, string)”public OpenCodeConsoleProvider(HttpClient? http = null, string consoleUrl = "https://opencode.ai/console")Parameters
| Name | Type | Description |
|---|---|---|
http |
HttpClient | Sends the login’s own requests. Unset, a shared client. |
consoleUrl |
string | Test seam. |
Fields
Section titled “Fields”DefaultConsoleUrl
Section titled “DefaultConsoleUrl”public const string DefaultConsoleUrl = "https://opencode.ai/console"Value: string
GoPrefix
Section titled “GoPrefix”public const string GoPrefix = "go/"Value: string
InferenceUrl
Section titled “InferenceUrl”public const string InferenceUrl = "https://opencode.ai/inference"Value: string
Properties
Section titled “Properties”ApiKeyEnv
Section titled “ApiKeyEnv”public string? ApiKeyEnv { get; }The variable whose API key the provider’s calls and model list read in place of the stored login.
Value: string
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)Leaves out disabled models and Zen’s free ones, which only OpenCode’s own clients may use.
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)Names the workspace as each API expects it.
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>