[GH-ISSUE #73] ERROR: exception 'SpotifyWebAPI\SpotifyWebAPIException' with message 'Authorization code expired' in /var/www/html/vendor/jwilsson/spotify-web-api-php/src/Request.php:42 #39

Closed
opened 2026-02-27 19:25:44 +03:00 by kerem · 2 comments
Owner

Originally created by @ashishbaltech on GitHub (Mar 28, 2017).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/73

I am still getting

[2017-03-28 02:46:33] production.ERROR: exception 'SpotifyWebAPI\SpotifyWebAPIException' with message 'Authorization code expired' in /var/www/html/vendor/jwilsson/spotify-web-api-php/src/Request.php:42

Stack trace:

#0 /var/www/html/vendor/jwilsson/spotify-web-api-php/src/Request.php(240): SpotifyWebAPI\Request->parseBody('{"error":"inval...', 400)

this error? Please comment on this?

Using code

$session = new SpotifyWebAPI\Session( env('SPOTIFY_CLIENT_ID'), env('SPOTIFY_CLIENT_SECRET'), env('SPOTIFY_CALLBACK_URL') );

           $api = new SpotifyWebAPI\SpotifyWebAPI();

           $code = trim($oRequest->input('code'));
           $session->requestAccessToken($code);
           $api->setAccessToken($session->getAccessToken());
           $me = $api->me();
           Session::put('spotify_token', $session->getAccessToken());
Originally created by @ashishbaltech on GitHub (Mar 28, 2017). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/73 I am still getting [2017-03-28 02:46:33] production.ERROR: exception 'SpotifyWebAPI\SpotifyWebAPIException' with message 'Authorization code expired' in /var/www/html/vendor/jwilsson/spotify-web-api-php/src/Request.php:42 Stack trace: #0 /var/www/html/vendor/jwilsson/spotify-web-api-php/src/Request.php(240): SpotifyWebAPI\Request->parseBody('{"error":"inval...', 400) this error? Please comment on this? Using code ``` $session = new SpotifyWebAPI\Session( env('SPOTIFY_CLIENT_ID'), env('SPOTIFY_CLIENT_SECRET'), env('SPOTIFY_CALLBACK_URL') ); $api = new SpotifyWebAPI\SpotifyWebAPI(); $code = trim($oRequest->input('code')); $session->requestAccessToken($code); $api->setAccessToken($session->getAccessToken()); $me = $api->me(); Session::put('spotify_token', $session->getAccessToken()); ```
kerem 2026-02-27 19:25:44 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jwilsson commented on GitHub (Mar 28, 2017):

As the error message states, the authorization code has expired.

Somehow, the time between your app requesting authorization and the time your app requests an access token using the authorization code was too long. The authorization code is usually only valid for a few minutes, perhaps you're caching something somewhere or similar?

<!-- gh-comment-id:289855500 --> @jwilsson commented on GitHub (Mar 28, 2017): As the error message states, the authorization code has expired. Somehow, the time between your app requesting authorization and the time your app requests an access token using the authorization code was too long. The authorization code is usually only valid for a few minutes, perhaps you're caching something somewhere or similar?
Author
Owner

@jwilsson commented on GitHub (May 6, 2017):

Closing this due to inactivity. Please leave a comment if you need anything else!

<!-- gh-comment-id:299620323 --> @jwilsson commented on GitHub (May 6, 2017): Closing this due to inactivity. Please leave a comment if you need anything else!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-web-api-php#39
No description provided.