apps/docs/content/guides/auth/social-login/auth-spotify.mdx
To enable Spotify Auth for your project, you need to set up a Spotify OAuth application and add the application credentials to your Supabase Dashboard.
Setting up Spotify logins for your application consists of 3 parts:
API Key and API Secret Key to your Supabase Project.<$Partial path="social_provider_setup.mdx" variables={{ "provider": "Spotify" }} />
Create an AppApp nameApp descriptionDeveloper TOS and Branding GuidelinesCreateClient IDClient SecretEdit SettingsUnder Redirect URIs:
AddSave at the bottom<$Partial path="social_provider_settings_supabase.mdx" variables={{ "provider": "Spotify" }} />
You can also configure the Spotify auth provider using the Management API:
# Get your access token from https://supabase.com/dashboard/account/tokens
export SUPABASE_ACCESS_TOKEN="your-access-token"
export PROJECT_REF="your-project-ref"
# Configure Spotify auth provider
curl -X PATCH "https://api.supabase.com/v1/projects/$PROJECT_REF/config/auth" \
-H "Authorization: Bearer $SUPABASE_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"external_spotify_enabled": true,
"external_spotify_client_id": "your-spotify-client-id",
"external_spotify_secret": "your-spotify-client-secret"
}'
The following outlines the steps to sign in using Spotify with Supabase Auth.
<Tabs scrollable size="small" type="underlined" defaultActiveId="js" queryGroup="language"
<TabPanel id="js" label="JavaScript">
<$Partial path="create_client_snippet.mdx" />
When your user signs in, call signInWithOAuth() with spotify as the provider:
import { createClient } from '@supabase/supabase-js'
const supabase = createClient('<your-project-url>', '<sb_publishable_... or anon key>')
// ---cut---
async function signInWithSpotify() {
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'spotify',
})
}
When your user signs in, call signInWithOAuth() with spotify as the provider:
Future<void> signInWithSpotify() async {
await supabase.auth.signInWithOAuth(
OAuthProvider.spotify,
redirectTo: kIsWeb ? null : 'my.scheme://my-host', // Optionally set the redirect link to bring back the user via deeplink.
authScreenLaunchMode:
kIsWeb ? LaunchMode.platformDefault : LaunchMode.externalApplication, // Launch the auth screen in a new webview on mobile.
);
}
When your user signs in, call signInWith(Provider) with Spotify as the Provider:
suspend fun signInWithSpotify() {
supabase.auth.signInWith(Spotify)
}
<$Partial path="oauth_pkce_flow.mdx" />
<Tabs scrollable size="small" type="underlined" defaultActiveId="js" queryGroup="language"
<TabPanel id="js" label="JavaScript">
When your user signs out, call signOut() to remove them from the browser session and any objects from localStorage:
import { createClient } from '@supabase/supabase-js'
const supabase = createClient('<your-project-url>', '<sb_publishable_... or anon key>')
// ---cut---
async function signOut() {
const { error } = await supabase.auth.signOut()
}
When your user signs out, call signOut() to remove them from the browser session and any objects from localStorage:
Future<void> signOut() async {
await supabase.auth.signOut();
}
When your user signs out, call signOut() to remove them from the browser session and any objects from localStorage:
suspend fun signOut() {
supabase.auth.signOut()
}