CodexProvider
Namespace: E2E.OAuth
public sealed class CodexProvider : IOAuthProviderChatGPT Plus/Pro through the Codex OAuth client: PKCE authorization code against auth.openai.com with a
local callback on port 1455, or OpenAI’s user-code flow for a machine without a browser. Requests go to the
Codex backend, which speaks the Responses API, requires store: false, and answers only as a stream.
Inheritance: object
Implements: IOAuthProvider
Constructors
Section titled “Constructors”CodexProvider(HttpClient?, string, string, string, int, TimeSpan?)
Section titled “CodexProvider(HttpClient?, string, string, string, int, TimeSpan?)”public CodexProvider(HttpClient? http = null, string originator = "e2e", string issuer = "https://auth.openai.com", string apiUrl = "https://chatgpt.com/backend-api/codex/responses", int callbackPort = 1455, TimeSpan? loginTimeout = null)Parameters
| Name | Type | Description |
|---|---|---|
http |
HttpClient | Sends the login’s own requests. Unset, a shared client. |
originator |
string | The originator the authorization page and requests carry: your product’s name. |
issuer |
string | Test seam. |
apiUrl |
string | Test seam. |
callbackPort |
int | Test seam. |
loginTimeout |
TimeSpan? | Test seam. |
Fields
Section titled “Fields”DefaultApiUrl
Section titled “DefaultApiUrl”public const string DefaultApiUrl = "https://chatgpt.com/backend-api/codex/responses"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 models the Codex backend serves this subscription, /models next to /responses. Hidden ones are listed, marked.
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)Routes a Responses request at the Codex backend with the body the Codex CLI sends: no server-side storage, encrypted reasoning carried between turns, always streamed. The model folds the stream back.
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>