Skip to main content

AuthProvider

interface

An authentication provider a mod contributes, as returned by authProvider.

interface AuthProvider

Import

import { AuthProvider } from '@modular/sdk';

Members6

createSession
(scopes: readonly string[], options: AuthProviderSessionOptions, ctx: AuthProviderContext) => Promise<AuthenticationSession>

Run the interactive sign-in and return the new session. Only called when AuthProvider.getSessions came back empty and the caller asked for `createIfNone`. This is where prompting and browser redirects belong. Store the token in `ctx.secrets` before returning.

getSessions
(scopes: readonly string[] | undefined, options: AuthProviderSessionOptions, ctx: AuthProviderContext) => Promise<readonly AuthenticationSession[]>

Return sessions already signed in, without any user interaction. Called first on every lookup. Return an empty array when there is nothing stored. Do not sign the user in from here.

id
string

Provider id callers pass to `ctx.auth.getSession`.

kind
'auth-provider'
label
string

Name of the service as the user sees it, for example `GitHub`.

removeSession
(sessionId: string, ctx: AuthProviderContext) => Promise<void>

Sign out. Delete the stored credential and revoke it if the service allows.

Notes

category
Authoring