src/Session.php
public function requestAccessToken($authorizationCode)
    {
        $parameters = [
            'client_id' => $this->getClientId(),
            'client_secret' => $this->getClientSecret(),
            'code' => $authorizationCode,
            'grant_type' => 'authorization_code',
            'redirect_uri' => $this->getRedirectUri(),
        ];

        $response = $this->request->account('POST', '/api/token', $parameters, []);
        $response = $response['body'];

        if (isset($response->refresh_token) && isset($response->access_token)) {
            $this->refreshToken = $response->refresh_token;
            $this->accessToken = $response->access_token;
            $this->expirationTime = time() + $response->expires_in;
            $this->scope = isset($response->scope) ? $response->scope : $this->scope;

            return true;
        }

        return false;
    }
public function requestAccessToken($authorizationCode)
    {
        $parameters = [
            'client_id' => $this->getClientId(),
            'client_secret' => $this->getClientSecret(),
            'code' => $authorizationCode,
            'grant_type' => 'authorization_code',
            'redirect_uri' => $this->getRedirectUri(),
        ];

        $response = $this->request->account('POST', '/api/token', $parameters, []);
        $response = $response['body'];

        if (isset($response->refresh_token) && isset($response->access_token)) {
            $this->refreshToken = $response->refresh_token;
            $this->accessToken = $response->access_token;
            $this->expirationTime = time() + $response->expires_in;
            $this->scope = isset($response->scope) ? $response->scope : $this->scope;

            return true;
        }

        return false;
    }
public function requestAccessToken ( $ authorizationCode ) { $ parameters = [ 'client_id' => $ this -> getClientId ( ) , 'client_secret' => $ this -> getClientSecret ( ) , 'code' => $ authorizationCode , 'grant_type' => 'authorization_code' , 'redirect_uri' => $ this -> getRedirectUri ( ) , ] ; $ response = $ this -> request -> account ( 'POST' , '/api/token' , $ parameters , [ ] ) ; $ response = $ response [ 'body' ] ; if ( isset ( $ response -> refresh_token ) && isset ( $ response -> access_token ) ) { $ this -> refreshToken = $ response -> refresh_token ; $ this -> accessToken = $ response -> access_token ; $ this -> expirationTime = time ( ) + $ response -> expires_in ; $ this -> scope = isset ( $ response -> scope ) ? $ response -> scope : $ this -> scope ; return true ; } return false ; }
Request an access token given an authorization code.

@param string $authorizationCode The authorization code from Spotify.

@return bool True when the access token was successfully granted, false otherwise.
Request an access token given an authorization code .