From 44f8764a4c13ceb5c520b01ae40e4080deec27b0 Mon Sep 17 00:00:00 2001 From: Yizack Rangel Date: Tue, 17 Mar 2026 05:59:13 -0500 Subject: [PATCH 1/2] chore: add types for Spotify provider --- src/runtime/server/lib/oauth/spotify.ts | 30 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/runtime/server/lib/oauth/spotify.ts b/src/runtime/server/lib/oauth/spotify.ts index 72c21af7..b446614b 100644 --- a/src/runtime/server/lib/oauth/spotify.ts +++ b/src/runtime/server/lib/oauth/spotify.ts @@ -55,7 +55,31 @@ export interface OAuthSpotifyConfig { redirectURL?: string } -export function defineOAuthSpotifyEventHandler({ config, onSuccess, onError }: OAuthConfig) { +interface SpotifyUser { + display_name: string + external_urls: { + spotify: string + } + href: string + id: string + images: { + url: string + height: number + width: number + }[] + type: string + uri: string +} + +interface SpotifyTokens { + access_token: string + token_type: string + scope: string + expires_in: number + refresh_token: string +} + +export function defineOAuthSpotifyEventHandler({ config, onSuccess, onError }: OAuthConfig) { return eventHandler(async (event: H3Event) => { config = defu(config, useRuntimeConfig(event).oauth?.spotify, { authorizationURL: 'https://accounts.spotify.com/authorize', @@ -106,9 +130,7 @@ export function defineOAuthSpotifyEventHandler({ config, onSuccess, onError }: O const accessToken = tokens.access_token - // TODO: improve typing - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const user: any = await $fetch('https://api.spotify.com/v1/me', { + const user = await $fetch('https://api.spotify.com/v1/me', { headers: { Authorization: `Bearer ${accessToken}`, }, From d35d6c17d0023bccc97260d788353f28190b4e96 Mon Sep 17 00:00:00 2001 From: Yizack Rangel Date: Tue, 17 Mar 2026 06:06:01 -0500 Subject: [PATCH 2/2] chore: remove deprecated email scope --- src/runtime/server/lib/oauth/spotify.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/runtime/server/lib/oauth/spotify.ts b/src/runtime/server/lib/oauth/spotify.ts index b446614b..23b344ba 100644 --- a/src/runtime/server/lib/oauth/spotify.ts +++ b/src/runtime/server/lib/oauth/spotify.ts @@ -21,14 +21,9 @@ export interface OAuthSpotifyConfig { * Spotify OAuth Scope * @default [] * @see https://developer.spotify.com/documentation/web-api/concepts/scopes - * @example ['user-read-email'] + * @example ['playlist-read-private'] */ scope?: string[] - /** - * Require email from user, adds the ['user-read-email'] scope if not present - * @default false - */ - emailRequired?: boolean /** * Spotify OAuth Authorization URL @@ -96,9 +91,6 @@ export function defineOAuthSpotifyEventHandler({ config, onSuccess, onError }: O if (!query.code) { config.scope = config.scope || [] - if (config.emailRequired && !config.scope.includes('user-read-email')) { - config.scope.push('user-read-email') - } // Redirect to Spotify Oauth page return sendRedirect( event,