Type in your question below and we'll check to see what answers we can find...
Loading article...
Submitting...
If you couldn't find any answers in the previous step then we need to post your question in the community and wait for someone to respond. You'll be notified when that happens.
Simply add some detail to your question and refine the title if needed, choose the relevant category, then post.
Before we can post your question we need you to quickly make an account (or sign in if you already have one).
Don't worry - it's quick and painless! Just click below, and once you're logged in we'll bring you right back here and post your question. We'll remember what you've already typed in so you won't have to do it again.
Please see below the most popular frequently asked questions.
Loading article...
Loading faqs...
Please see below the current ongoing issues which are under investigation.
Loading issue...
Loading ongoing issues...
Hi,
I can't create a playlist for my own user
https://developer.spotify.com/documentation/web-api/tutorials/getting-started#request-artist-data
I always get
“status”: 403, “message”: “You cannot create a playlist for another user”
I can do other things, like get artist info.
I got the user ID from the profile page and it also what I get back from the PKCE example: https://github.com/spotify/web-api-examples/tree/master/authorization/authorization_code_pkce
This is my example code:
<?php
/* GET AUTHORIZATION */
$post = [
'grant_type' => 'client_credentials',
'scope' => 'playlist-modify-public playlist-modify-private',
];
$ch = curl_init('https://accounts.spotify.com/api/token');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Basic ' . base64_encode('{CLIENT_ID}:{CLIENT_SECRET}'),
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( $post ) );
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode( $response, 1 );
/* ADD PLAYLIST */
$ch = curl_init('https://api.spotify.com/v1/users/{USER_ID}/playlists');
$playlist = json_encode( array( 'name' => 'Pandafish Test', 'description' => 'Testing the API', 'public' => 'true' ) );
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type:application/json',
'Authorization: Bearer ' . $response[ 'access_token' ],
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $playlist );
$playlist = curl_exec($ch);
curl_close($ch);
Thanks for having a look.
Kind regards,
Stijn
It looks like you are trying to mix Client Credentials with the the PKCE flow.
I recommend you to start over and only use code from that flow.
Hi Ximzend.
Thanks for replying, but I think you misunderstand. I'm not using PKCE, only the code in my example.
I was just using the PKCE workflow from Github to see if the user ID I got from the profile page was the correct one to use for creating a play list.
hi Stijn,
Then there is the problem: you can't access user data like this with Client Credentials.
Hi Ximzend,
not even your own playlist? The Web app is created specifically with this user.
Hi Stijn,
You don't log in with Client Credentials, so the generated token is never linked to an account. Therefore you can't get your own playlists that are not publicly displayed at your profile.
Cheers,
Vincent
Additionally, you can get your publicly displayed playlists with Client Credentials without the need of using Authorization Scopes.
Hi Vincent,
first of, thanks for the help so far.
I'm actually (public) trying to create a playlist.
Just to be sure: I am using the credentials in the actual code, I am just replacing them with {CLIENT_ID} etc. in my example above.
I am using the authorization flow from the example here: https://developer.spotify.com/documentation/web-api/tutorials/getting-started#request-an-access-toke...
That is Client Credentials flow, right?
What would I have to change to the authorization to be able to publish public playlists on my own profile?
Thanks.
Hi Stijn,
The first tutorial uses indeed Client Credentials.
Client Credentials are not linked to any account, so to create a playlist for you or another user, Authorization is required.
Yes. I got it working!
Like Ximzend said, you need to use the Authorization flow to be able to edit playlists: https://developer.spotify.com/documentation/web-api/tutorials/code-flow
This Stack Overflow question also helped me a lot:
Hey there you, Yeah, you! 😁 Welcome - we're glad you joined the Spotify Community! While you here, let's have a fun game and get…