Announcements

Help Wizard

Step 1

NEXT STEP

https://api.spotify.com/v1/me/albums returns 500 - Internal Server Error

Solved!

https://api.spotify.com/v1/me/albums returns 500 - Internal Server Error

 

Plan

Premium

Country

USA

 

Device

Macbook Air M1 (via curl and Postman)

Operating System

MacOs

 

My Question or Issue

I am attempting to get a list of my saved albums and their respective URLs.  To begin, I set up a Postman collection to get the authorization token:
Auth Type: Oauth 2.0

Auth date to : request headers

token name: access_token

grant type: client credentials

access token url: https://accounts.spotify.com/api/token

client id: *

client secret: **

scope: user-library-read

client authentication: send as basic auth header

 

I get the new access token and set it to the current token to be used for all spotify requests.

Header prefix : Bearer 

 

I test it on publicly available data:

curl "https://api.spotify.com/v1/artists/4Z8W4fKeB5YxbusRsdQVPb" -H "Authorization: Bearer {the token received above}"
 
and it works.
Then I try to get my saved albums:
--header 'limit: 50' \
--header 'Authorization: Bearer {the same access token}'
 
and I get a 500 error.  I ALWAYS get a 500 error.  The docs told me to alert Spotify if I ever get a 500 because there is something clearly going wrong with the backend code.  Please help me fix this.
 
Thank you!

 

Reply

Accepted Solutions
Marked as solution

You can choose another OAutfow from this page.

If you want to run the code at a back-end server, you can use the Authorization code flow.

If you want to run all the code inside your browser, you should use the Authorization code with PKCE extension.

View solution in original post

6 Replies

Can I edit these posts?  Where's the button for that?

Anyway that authorization setting up there is supposed to be:
Add auth data to : request headers

Authorization and Client Credentials are two different things. You can't authorize with client credentials.

Care to explain further?  I don't know what you mean. I am obtaining a token from this workflow that allows me to GET other api calls without issue. It has the scopes necessary for this API call according to the documentation.  I am not getting a 4xx error about my credentials.  The fact that its returning a 500 at all is a problem, the application should be catching the problem and responding with a more useful error message.

In your code I see grant type: client credentials

You simply can't access (your) user data with client credentials; only endpoints that don't access user data can use client credentials.

ok cool I think I'm getting the idea.  so what do I do?

Marked as solution

You can choose another OAutfow from this page.

If you want to run the code at a back-end server, you can use the Authorization code flow.

If you want to run all the code inside your browser, you should use the Authorization code with PKCE extension.

Suggested posts