src/TiendaNube/Auth.php
public function request_access_token($code){
        $params = [
            'client_id' => $this->client_id,
            'client_secret' => $this->client_secret,
            'code' => $code,
            'grant_type' => 'authorization_code',
        ];
        
        $response = $this->requests->post($this->auth_url, [], $params);
        if (!$response->success){
            throw new Auth\Exception('Auth url returned with status code ' . $response->status_code);
        }
        
        $body = json_decode($response->body);
        if (isset($body->error)){
            throw new Auth\Exception("[{$body->error}] {$body->error_description}");
        }
        
        return [
            'store_id' => $body->user_id,
            'access_token' => $body->access_token,
            'scope' => $body->scope,
        ];
    }
public function request_access_token($code){
        $params = [
            'client_id' => $this->client_id,
            'client_secret' => $this->client_secret,
            'code' => $code,
            'grant_type' => 'authorization_code',
        ];
        
        $response = $this->requests->post($this->auth_url, [], $params);
        if (!$response->success){
            throw new Auth\Exception('Auth url returned with status code ' . $response->status_code);
        }
        
        $body = json_decode($response->body);
        if (isset($body->error)){
            throw new Auth\Exception("[{$body->error}] {$body->error_description}");
        }
        
        return [
            'store_id' => $body->user_id,
            'access_token' => $body->access_token,
            'scope' => $body->scope,
        ];
    }
public function request_access_token ( $ code ) { $ params = [ 'client_id' => $ this -> client_id , 'client_secret' => $ this -> client_secret , 'code' => $ code , 'grant_type' => 'authorization_code' , ] ; $ response = $ this -> requests -> post ( $ this -> auth_url , [ ] , $ params ) ; if ( ! $ response -> success ) { throw new Auth \ Exception ( 'Auth url returned with status code ' . $ response -> status_code ) ; } $ body = json_decode ( $ response -> body ) ; if ( isset ( $ body -> error ) ) { throw new Auth \ Exception ( "[{$body->error}] {$body->error_description}" ) ; } return [ 'store_id' => $ body -> user_id , 'access_token' => $ body -> access_token , 'scope' => $ body -> scope , ] ; }
Obtain a permanent access token from an authorization code.

@param string $code Authorization code retrieved from the redirect URI.
Obtain a permanent access token from an authorization code .