mirror of
https://github.com/jwilsson/spotify-web-api-php.git
synced 2026-04-26 23:45:49 +03:00
[GH-ISSUE #244] Error 403 (Forbidden)!! on requestAccessToken() #175
Labels
No labels
bug
docs
enhancement
enhancement
enhancement
feedback wanted
good first issue
help wanted
help wanted
help wanted
invalid
pull-request
question
question
upstream
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotify-web-api-php#175
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @moonswim on GitHub (Jan 7, 2022).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/244
Hello there!!
Im running into an issue which wasn't a problem before...
The code keeps getting stuck in.
In the Request.php the function handleResponseError()
// Something else went wrong, try to give at least some info
throw new SpotifyWebAPIException($body, $status);
I have dd()-d and checked if im passing everything correctly and it seems like i do.
In my controller keeps pointing to this line of error:
$session->requestAccessToken($code);
where before it i have:
$spotifyAccount = SpotifyAccount::where('id', 1)->first();
$session = new SpotifyWebAPI\Session(
$spotifyAccount->client_id,
$spotifyAccount->client_secret,
$spotifyAccount->redirect_uri
);
$code = $_GET['code'];
i have everything correct as the client_id, client_secret and redirect_uri.
Checking the function of requestAccessToken i realized that you don't pass any header to it which on the Spotify Web Api guides said you must include these:
HEADER PARAMETER | VALUE
Authorization | RequiredBase 64 encoded string that contains the client ID and client secret key. The field must have the
format: Authorization: Basic
Content-Type | RequiredSet to application/x-www-form-urlencoded.
But after adding the missing header i get the same error, which is an Error 403 (Forbidden)!!...
Please could you give me any tip on what im a not seeing :(
@jwilsson commented on GitHub (Jan 8, 2022):
Hey!
This sounds strange. Are you getting any more info than just 403? Is the message just "Forbidden" or are you getting something more?
It's a bit strange that Spotify's docs no longer mentions the access token request method used by this library (that code has looked the same for years and everything is working when I try it locally). I did make some updates to follow their new docs and please test it out (it's located in a new branch which you can install with
composer require jwilsson/spotify-web-api-php:dev-session-refactor).@moonswim commented on GitHub (Jan 9, 2022):
Hello there first of all thank you for the fast reply!!
I did update the package from the branch you mentioned but it keeps doing the same...
@jwilsson commented on GitHub (Jan 10, 2022):
That looks like an error from Google, very strange. It doesn't look like it's even making its way to Spotify but some Google URL instead. Where are you hosting it? Google Cloud? Have you tried running it locally and see if it works there?
@moonswim commented on GitHub (Jan 10, 2022):
Its being hosted on Linode, since December 8 or 9 i'm having this issue, before that it was working fine.

I can get up to here:
Okey, i was about to rewrite my message because i just tried it like i did for the past month and now it worked...
Yesterday i was doing the php artisan config:clear and php artisan cache:clear after the integration of your new branch but it did not work now i have no clue why it did....
I did not change anything, same computer, same terminal, same code its weird and worrying because something seems unstable and i don't know what :(
Thank you very much again for the response your library is awesome and it helped me to save a ton of time, up until now i didn't experience any problem with it.
Thanks again and you are awesome!
Cheers!
@jwilsson commented on GitHub (Jan 11, 2022):
Just so I'm following 😅 everything's working now? If so, awesome! Let's hope it keeps working then!
@moonswim commented on GitHub (Jan 11, 2022):
Yes it is currently working, and the refreshAccessToken is fine, when the expiration time is over it gets the new one so i don't know what happened or why but for now i close this issue.
Thank you!