Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Status Code 403 from Spotify API When Requesting User's Top Tracks and Top Artists

Solved!

Status Code 403 from Spotify API When Requesting User's Top Tracks and Top Artists

*Update I can query the artists node by providing their ID I only get 403 when querying the /me endpoint*

Working on a react application that allows a user to log in to Spotify and then displays their top 10 tracks and top 10 artists.

 

I can login with no problem, but when I request a users top tracks and artists I get this response from the API:

 

Failed to load resource: the server responded with a status of 403 ()

 

The account has been added to my Spotify dashboard, which I thought was the issue at first.

 

I've also tried writing the request with axios.get() and fetch(), both had the same status code.

 

Is there something wrong with my authorization flow? Or is the request improperly formatted?

 

My App.js and LogButton.js files which contain the authorization and request flows are attached

 

TYIA! Any help is greatly appreciated

Reply

Accepted Solutions
Marked as solution

I was missing the scope param on my authorize request. Scope defines what actions I'd like to be able to perform on behalf of the user. 

Here's an example: 

const SCOPE = 'user-read-private user-read-email user-read-playback-state user-modify-playback-state user-read-recently-played user-top-read';

Happy coding!

View solution in original post

3 Replies

I don't know what's wrong with your code.

But, because your client secret is in the code you've shared, I recommend you to reset it. (And change the old one in your code for the new one.)

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Thank you! Just realized I made a copy before I removed those whoops.

 

Marked as solution

I was missing the scope param on my authorize request. Scope defines what actions I'd like to be able to perform on behalf of the user. 

Here's an example: 

const SCOPE = 'user-read-private user-read-email user-read-playback-state user-modify-playback-state user-read-recently-played user-top-read';

Happy coding!

Suggested posts

Type a product name