Skip to content

OAuthProviders

Namespace: E2E.OAuth

public static class OAuthProviders

The built-in subscription providers by id, and what e2e login, logout, and models do with them.

Inheritance: object

View source

public static IReadOnlyList<string> Ids { get; }

Upstream’s provider ids, in its order.

Value: IReadOnlyList<string>

View source

public static string? ApiKeyFor(IOAuthProvider provider)

The provider’s API key from its ApiKeyEnv variable, when that is set.

Parameters

Name Type Description
provider IOAuthProvider

Returns: string

View source

CredentialSource(IOAuthProvider, ICredentialStore?)

Section titled “CredentialSource(IOAuthProvider, ICredentialStore?)”
public static (ICredentialStore Store, string LoginHint) CredentialSource(IOAuthProvider provider, ICredentialStore? store = null)

Where <code class=“paramref”>provider</code>’s calls read their credential: the API key, when set, as a login with nothing to refresh, else <code class=“paramref”>store</code>, the default store unless given. The default store is only opened without a key, so a malformed E2E_OAUTH_CREDENTIALS does not block the key. The hint names the remedy for the credential actually read.

Parameters

Name Type Description
provider IOAuthProvider
store ICredentialStore

Returns: (ICredentialStore Store, string LoginHint)

View source

public static string Describe(string id)

A short description of each subscription, for pickers and help.

Parameters

Name Type Description
id string

Returns: string

View source

public static IOAuthProvider Get(string id)

The provider for <code class=“paramref”>id</code>; Misconfigured for an unknown id.

Parameters

Name Type Description
id string

Returns: IOAuthProvider

View source

ListModelsAsync(string, ICredentialStore?, CancellationToken)

Section titled “ListModelsAsync(string, ICredentialStore?, CancellationToken)”
public static Task<IReadOnlyList<SubscriptionModel>> ListModelsAsync(string providerId, ICredentialStore? store = null, CancellationToken cancellationToken = default)

The models <code class=“paramref”>providerId</code>’s credential serves: its API key when set, as its model constructor reads it, else the stored login; NotLoggedIn without either.

Parameters

Name Type Description
providerId string
store ICredentialStore
cancellationToken CancellationToken

Returns: Task<IReadOnlyList<SubscriptionModel>>

View source

LoginAsync(string, OAuthLoginCallbacks, OAuthLoginOptions?, ICredentialStore?, CancellationToken)

Section titled “LoginAsync(string, OAuthLoginCallbacks, OAuthLoginOptions?, ICredentialStore?, CancellationToken)”
public static Task<OAuthCredentials> LoginAsync(string providerId, OAuthLoginCallbacks callbacks, OAuthLoginOptions? options = null, ICredentialStore? store = null, CancellationToken cancellationToken = default)

Signs in to <code class=“paramref”>providerId</code> and stores the credentials.

Parameters

Name Type Description
providerId string
callbacks OAuthLoginCallbacks
options OAuthLoginOptions
store ICredentialStore
cancellationToken CancellationToken

Returns: Task<OAuthCredentials>

View source

public static string LoginHint(IOAuthProvider provider)

How a missing login is described to the user: the CLI command that fixes it, and the API key variable that does too.

Parameters

Name Type Description
provider IOAuthProvider

Returns: string

View source

LogoutAsync(string, ICredentialStore?, CancellationToken)

Section titled “LogoutAsync(string, ICredentialStore?, CancellationToken)”
public static Task<bool> LogoutAsync(string providerId, ICredentialStore? store = null, CancellationToken cancellationToken = default)

Forgets the stored login. True when one was stored.

Parameters

Name Type Description
providerId string
store ICredentialStore
cancellationToken CancellationToken

Returns: Task<bool>

View source