spotify/web-api-examples

Authorization Flow Doesn't Work

Closed this issue · 1 comments

bndnio commented

When attempting to setup a new project with Spotify authentication, I'm running into the following issue upon completing the Spotify authorization.

This has been reproduced with the code example from this repo.

Webpage:
Screenshot 2023-09-07 at 3 01 53 PM

Console:
Screenshot 2023-09-07 at 2 57 41 PM

Network Tab:
Screenshot 2023-09-07 at 3 11 09 PM

Steps to reproduce:

  • Clone this repository
  • yarn to install dependencies
  • cd to web-api-examples/authentication/authorization_code
  • populate client_id, client_secret, redirect_uri, with your project specific values
  • node app.js
  • visit web page (localhost:8888)
  • click "login with Spotify"
  • authorize using your account
  • -- land on error page --

It strikes me as very curious why the Spotify code is redirecting to https://accounts.spotify.com/{2}

I'm running on a 2022 M2 Macbook Air, macOS 13.0, with node v20.1.0, and yarn v1.22.19

bndnio commented

Figured out the problem! My redirect URI didn't have a protocol on it (both in my code & in the Spotify dev console).

localhost:3000/account is invalid.
Changing it to http://localhost:3000/account resolves the issue.

If at all possible, it would be helpful to receive an error code explaining the problem instead of an html page describing a generic error, or validation in the Spotify developer console.

Hopefully this is helpful for someone else in the future searching for this issue :)