OAuth integration for Spotify. Refer to Spotify OAuth documentation for getting the required credentials. Provider id is spotify
.
import { spotify } from "@lucia-auth/oauth/providers";
import { auth } from "./lucia.js";
const spotifyAuth = spotify(auth, config);
spotify()
#
const spotify: (
auth: Auth,
configs: {
clientId: string;
clientSecret: string;
redirectUri: string;
scope?: string[];
}
) => SpotifyProvider;
Parameters#
name | type | description | optional |
---|
auth | Auth | Lucia instance | |
config.clientId | string | Spotify OAuth app client id | |
config.clientSecret | string | Spotify OAuth app client secret | |
config.redirectUri | string | one of the authorized redirect URIs | |
config.scope | string[] | an array of scopes | ✓ |
Returns#
Interfaces#
SpotifyAuth
#
See OAuth2ProviderAuth
.
// implements OAuth2ProviderAuth<SpotifyAuth<_Auth>>
interface SpotifyAuth<_Auth extends Auth> {
getAuthorizationUrl: () => Promise<readonly [url: URL, state: string]>;
validateCallback: (code: string) => Promise<SpotifyUserAuth<_Auth>>;
}
Generics#
name | extends | default |
---|
_Auth | Auth | Auth |
SpotifyTokens
#
type SpotifyTokens = {
accessToken: string;
tokenType: string;
scope: string;
accessTokenExpiresIn: number;
refreshToken: string;
};
SpotifyUser
#
type SpotifyUser = {
country?: string;
display_name: string | null;
email?: string;
explicit_content: {
filter_enabled?: boolean;
filter_locked?: boolean;
};
external_urls: {
spotify: string;
};
followers: {
href: string | null;
total: number;
};
href: string;
id: string;
images: [
{
url: string;
height: number | null;
width: number | null;
}
];
product?: string;
type: string;
uri: string;
};
SpotifyUserAuth
#
Extends ProviderUserAuth
.
interface SpotifyUserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> {
appleUser: SpotifyUser;
appleTokens: SpotifyTokens;
}
Generics#