OAuth integration for Twitter OAuth 2.0 with PKCE. The access token can only be used for Twitter API v2. Provider id is twitter
.
import { twitter } from "@lucia-auth/oauth/providers";
import { auth } from "./lucia.js";
const twitterAuth = twitter(auth, config);
const twitter: (
auth: Auth,
config: {
clientId: string;
clientSecret: string;
redirectUri: string;
scope?: string[];
}
) => TwitterProvider;
Parameter#
name | type | description | optional |
---|
auth | Auth | Lucia instance | |
config.clientId | string | client id | |
config.clientSecret | string | client id | |
config.redirectUri | string | redirect URI | |
config.scope | string[] | an array of scopes | ✓ |
Returns#
Interfaces#
See OAuth2ProviderAuthWithPKCE
.
// implements OAuth2ProviderAuthWithPKCE<TwitterAuth<_Auth>>
interface TwitterAuth<_Auth extends Auth> {
getAuthorizationUrl: () => Promise<
readonly [url: URL, codeVerifier: string, state: string]
>;
validateCallback: (code: string) => Promise<TwitterUserAuth<_Auth>>;
}
Generics#
name | extends | default |
---|
_Auth | Auth | Auth |
type TwitterTokens = {
accessToken: string;
refreshToken: string | null;
};
type TwitterUser = {
id: string;
name: string;
username: string;
};
Extends ProviderUserAuth
.
interface TwitterUserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> {
twitterUser: TwitterUser;
twitterTokens: TwitterTokens;
}
Generics#