Wrike重定向URI无效

时间:2018-02-28 21:29:43

标签: php oauth-2.0

首先我有这个链接

https://www.wrike.com/oauth2/authorize?client_id=<?php echo WRIKE_CLIENT_ID; ?>&response_type=code&redirect_uri=<?php echo urlencode(WRIKE_RETURN_URL); ?>

当我们点击网址时,它会将我重定向到WRIKE_RETURN_URL

但是当我尝试连接以连接到wrike API时,在重定向的页面上我有以下错误

重定向页面上的代码就像这样

        $fields = [
            'client_id'     => WRIKE_CLIENT_ID,
            'client_secret' => WRIKE_CLIENT_SECRET,
            'grant_type'    => 'authorization_code',                            
            'code'          => $code,
        ];

$ code变量,我通过$ _GET [&#39;代码&#39;]获取网址

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.wrike.com/oauth2/token");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch); 

我一直收到错误:

{ ["error"]=> string(13) "invalid_grant" ["error_description"]=> string(23) "Redirect URI is invalid" }

0 个答案:

没有答案