Description
Provider type
Spotify
Environment
## System:
- OS: Windows 11 10.0.22631
- CPU: (6) x64 Intel(R) Core(TM) i5-9400 CPU @ 2.90GHz
- Memory: 1.19 GB / 7.88 GB
## Binaries:
- Node: 20.12.0 - C:\Program Files\nodejs\node.EXE
- npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
## Browsers:
- Edge: Chromium (127.0.2651.74)
- Internet Explorer: 11.0.22621.3527
## npmPackages:
- next: 14.2.5 => 14.2.5
- next-auth: ^5.0.0-beta.20 => 5.0.0-beta.20
- react: ^18 => 18.3.1
Reproduction URL
https://github.com/sshuvoo/next-auth-example
Describe the issue
The Spotify provider in Auth.js doesn't support setting custom scopes through the authorization.params.scope
option, unlike other providers. This inconsistency makes it difficult to configure custom scopes for Spotify in the same way as other OAuth providers.
Currently, the Spotify provider has a hardcoded scope in its authorization URL:
{authorization:
"https://accounts.spotify.com/authorize?scope=user-read-email",}
This means that users can't easily customize the scopes without overriding the entire authorization URL. I've tried to use the standard configuration method used for other providers:
providers: [
Spotify({
authorization: {
params: {
scope: 'user-top-read user-read-email',
},
},
}),
]
However, this doesn't work as expected, and the default "user-read-email" scope is still used.
Current workaround (After analyzing source code (Spotify.ts)):
Spotify({
authorization: `https://accounts.spotify.com/authorize?scope=${encodeURIComponent('custom scopes here')}`,
})
How to reproduce
Set up a new Auth.js project with the Spotify provider.
Try to configure custom scopes using the standard method:
export const { handlers, auth } = NextAuth({
providers: [
Spotify({
authorization: {
params: {
scope: 'user-top-read user-read-email',
},
},
}),
],
})
Initiate the Spotify authentication flow.
Observe that the authorization URL still only includes the default "user-read-email" scope.
Expected behavior
The Spotify provider should respect the authorization.params.scope
option, similar to other OAuth providers in Auth.js. When custom scopes are specified, they should be included in the authorization URL sent to Spotify.
The expected behavior would allow users to configure Spotify scopes like this:
Spotify({
authorization: {
params: {
scope: 'user-top-read user-read-email',
},
},
})
This configuration should result in an authorization URL that includes all the specified scopes, allowing users to request the necessary permissions from Spotify without having to override the entire authorization URL.