成功获取访问令牌后出现401错误

时间:2019-01-28 08:47:49

标签: php oauth-2.0 slim

我的应用程序中的授权过程有问题。我可以获取访问令牌,但是仅当我将URL粘贴到浏览器中时才可以。它成功吐出令牌。但是,当我尝试通过代码向该特定网址发出请求时,它表示我未经授权。这是我第一次尝试使用oauth 2,我已经坐在这里大约2天了,无法解决问题。

编辑

请求:

$params = array(
    'client_id'     => $this->clientID,
    'response_type' => 'code',
    'scope'         => $this->scope,
    'state'         => 1,
);

$curl_response = RestClient::get( $this->url.'authorize?'.http_build_query($params) );

和RestClient :: get方法:

public static function get( $url, array $curlopt = [] ){
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    if ( !empty( $curlopt ) ){
        curl_setopt_array($curl, $curlopt);
    }
    $curl_response = curl_exec($curl);
    curl_close($curl);
    return $curl_response;
}

0 个答案:

没有答案