mirror of
https://github.com/jwilsson/spotify-web-api-php.git
synced 2026-04-27 07:55:49 +03:00
[GH-ISSUE #189] HTTP Error 500 on requestAccessToken() #124
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#124
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 @Keithtron on GitHub (May 3, 2020).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/189
Hi!
I've been going nuts trying to debug this error 500 I've been getting. The Spotify user authentication seems to go through ok, and when it redirects to the next PHP page, it errors on this: $session->requestAccessToken($_GET['code']);
I've gotten this working fine locally in XAMPP, but when I upload it to my AWS EC2 server (and change redirect URLs accordingly), it's not working.
I've stripped down that php page to only the following:
This executes fine if I comment out the requestAccessToken, but give error 500 when running that command.
Any ideas on this? Thanks in advance for any help you can provide!
@Keithtron commented on GitHub (May 3, 2020):
My localhost XAMPP is running php 7.3.11 with curl 7.64.0, and the EC2 server is running php 7.0.16 with curl 7.61.1. But I assume this shouldn't be an issue, since they're both version 7 with curl support.
@Keithtron commented on GitHub (May 3, 2020):
I've also tried your user data display example:
Same issue here, with the error 500 on requestAccessToken, but when I swap in the phpinfo() instead, that runs fine.
@jwilsson commented on GitHub (May 3, 2020):
Hey!
That's really strange! Can you see the exact PHP error you're getting?
For example, by putting this at the top of the file:
Thanks!
@Keithtron commented on GitHub (May 3, 2020):
Big thanks for the quick response!
Fatal error: Uncaught SpotifyWebAPI\SpotifyWebAPIAuthException: Invalid redirect URI in /var/www/html/hybrid-blak/gate/vendor/jwilsson/spotify-web-api-php/src/Request.php:65 Stack trace: #0 /var/www/html/hybrid-blak/gate/vendor/jwilsson/spotify-web-api-php/src/Request.php(265): SpotifyWebAPI\Request->parseBody(Object(stdClass), 400) #1 /var/www/html/hybrid-blak/gate/vendor/jwilsson/spotify-web-api-php/src/Request.php(115): SpotifyWebAPI\Request->send('POST', 'https://account...', 'client_id=692b4...', Array) #2 /var/www/html/hybrid-blak/gate/vendor/jwilsson/spotify-web-api-php/src/Session.php(217): SpotifyWebAPI\Request->account('POST', '/api/token', Array, Array) #3 /var/www/html/hybrid-blak/gate/index.php(17): SpotifyWebAPI\Session->requestAccessToken('AQC7yhTEh-lr04V...') #4 {main} thrown in /var/www/html/hybrid-blak/gate/vendor/jwilsson/spotify-web-api-php/src/Request.php on line 65While putting this thing together I was able to fix some other 'Invalid Redirect URI' errors, but I'm curious why this one would manifest as an Error 500 rather than displaying the error more directly, like it does with those extra error reporting settings. (Perhaps different error reporting settings on the real server vs my XAMPP localhost?)
The redirect URI in my call to '$session = new SpotifyWebAPI\Session(...)' seems to be valid and is included in the settings in the client dashboard.
@Keithtron commented on GitHub (May 3, 2020):
Looks like I got it working!
I had tried several different redirect URIs that matched entries in my client dashboard, all ending with "/", which had sounded like a recommendation from some other posts I had seen. But it finally worked when I set the redirect URI to match the currently running script.
Your suggestion to enable proper error reporting was a huge help, I couldn't have tracked this down otherwise. Thanks!
@jwilsson commented on GitHub (May 4, 2020):
Awesome, glad we got it working!
I think that's the case, different error reporting settings. Because it's throwing an exception, the default would be to trickle up and unless something catches it, it would eventually become a 500 error.