OAuth integration for Auth0. Refer to Auth0 OAuth documentation for getting the required credentials. Provider id is auth0
.
import { auth0 } from "@lucia-auth/oauth/providers";
import { auth } from "./lucia.js";
const auth0Auth = auth0(auth, config);
auth0()
#
const auth0: (
auth: Auth,
config: {
appDomain: string;
clientId: string;
clientSecret: string;
redirectUri: string;
scope?: string[];
}
) => Auth0Provider;
Parameters#
Scopes openid
and profile
are always included
name | type | description | optional |
---|
auth | Auth | Lucia instance | |
config.appDomain | string | Auth0 OAuth app domain | |
config.clientId | string | Auth0 OAuth app client id | |
config.clientSecret | string | Auth0 OAuth app client secret | |
config.redirectUri | string | Auth0 OAuth app redirect uri | |
config.scope | string[] | an array of scopes | ✓ |
Returns#
Interfaces#
Auth0Auth
#
See OAuth2ProviderAuth
.
// implements OAuth2ProviderAuth<Auth0Auth<_Auth>>
interface Auth0Auth<_Auth extends Auth> {
getAuthorizationUrl: () => Promise<readonly [url: URL, state: string]>;
validateCallback: (code: string) => Promise<Auth0UserAuth<_Auth>>;
}
Generics#
name | extends | default |
---|
_Auth | Auth | Auth |
Auth0Tokens
#
type Auth0Tokens = {
accessToken: string;
refreshToken: string;
idToken: string;
tokenType: string;
};
Auth0User
#
type Auth0User = {
id: string;
sub: string;
name: string;
picture: string;
locale: string;
updated_at: string;
given_name?: string;
family_name?: string;
middle_name?: string;
nickname?: string;
preferred_username?: string;
profile?: string;
email?: string;
email_verified?: boolean;
gender?: string;
birthdate?: string;
zoneinfo?: string;
phone_number?: string;
phone_number_verified?: boolean;
};
Auth0UserAuth
#
Extends ProviderUserAuth
.
interface Auth0UserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> {
auth0User: Auth0User;
auth0Tokens: Auth0Tokens;
}
Generics#