[GH-ISSUE #48] Access Token #26

Closed
opened 2026-02-27 19:25:40 +03:00 by kerem · 1 comment
Owner

Originally created by @ghost on GitHub (Jun 16, 2016).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/48

Hi again, im getting user's infos in normal way but when i change my page i can t reach api anymore. In error log it says Invalid authorization code when i set a session like ($_SESSION['spot_kod'] = $_GET['code'];) and trying to use it in another php file like;
$this->session->requestAccessToken($_SESSION['code']);
$this->api->setAccessToken($this->session->getAccessToken());

so what is problem here? how can i use api with a valid access token in another php file?

Originally created by @ghost on GitHub (Jun 16, 2016). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/48 Hi again, im getting user's infos in normal way but when i change my page i can t reach api anymore. In error log it says Invalid authorization code when i set a session like ($_SESSION['spot_kod'] = $_GET['code'];) and trying to use it in another php file like; $this->session->requestAccessToken($_SESSION['code']); $this->api->setAccessToken($this->session->getAccessToken()); so what is problem here? how can i use api with a valid access token in another php file?
kerem 2026-02-27 19:25:40 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jwilsson commented on GitHub (Jun 17, 2016):

Hi!
The code is only valid once, to request an access token. You need to pass the access token along instead, for example:

First page

$this->session->requestAccessToken($_GET['code']);
$_SESSION['spot_token'] = $this->session->getAccessToken();

Second page

$this->api->setAccessToken($_SESSION['spot_token']);
<!-- gh-comment-id:226691655 --> @jwilsson commented on GitHub (Jun 17, 2016): Hi! The code is only valid once, to request an access token. You need to pass the access token along instead, for example: First page ``` php $this->session->requestAccessToken($_GET['code']); $_SESSION['spot_token'] = $this->session->getAccessToken(); ``` Second page ``` php $this->api->setAccessToken($_SESSION['spot_token']); ```
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#26
No description provided.