Skip to content

Commit

Permalink
Merge pull request #17 from bklaing2/dev
Browse files Browse the repository at this point in the history
Added redirect from Spotify auth
  • Loading branch information
bklaing2 authored Jun 23, 2024
2 parents 6850c74 + 4ed0b3e commit 53ea908
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/routes/auth/sign-in/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import { SPOTIFY_REDIRECT } from "$env/static/private";
import { redirect } from '@sveltejs/kit'


const SCOPES = [
'user-follow-read',
'playlist-read-private',
'playlist-modify-public',
'playlist-modify-private',
'ugc-image-upload'
'user-follow-read',
'playlist-read-private',
'playlist-modify-public',
'playlist-modify-private',
'ugc-image-upload'
]


export const actions = {
default: async ({ locals }) => {
const { data, error } = await locals.supabase.auth.signInWithOAuth({
provider: 'spotify',
options: { scopes: SCOPES.join(' ') }
})
const { data, error } = await locals.supabase.auth.signInWithOAuth({
provider: 'spotify',
options: {
scopes: SCOPES.join(' '),
redirectTo: SPOTIFY_REDIRECT
}
})

if (error) throw new Error(error.message)
throw redirect(303, data.url as string)
}
}

if (error) throw new Error(error.message)
throw redirect(303, data.url as string)
}
}

0 comments on commit 53ea908

Please sign in to comment.