[英]… API Call oAuth2.0 Refresh Token issue PandaDocs
我在嘗試從PandaDocs API上提供的REFRESH_TOKEN獲取ACCESS_TOKEN時遇到問題。
為了從刷新令牌中獲取新的ACCESS_TOKEN,要發送的正確參數是什么?
我存儲了我最初通過身份驗證上傳文檔進行簽名時最初收到的刷新令牌。 現在,我想使用刷新令牌來獲取新的訪問令牌,以便檢查文檔上簽名的狀態。
我正在嘗試使用存儲的刷新令牌來獲取新的訪問令牌,但我不斷獲取的grant_type無效。
這是我的代碼。
$token = '(refreshtokenhere)';
$url = "https://app.pandadoc.com/oauth2/access_token";
$useragent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.3 Safari/533.2';
$ch = curl_init();
$headr = array();
$headr[] = 'Content-Type: application/json;charset=UTF-8';
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
$postfields['grant_type'] = 'refresh_token';
$postfields['refresh_token'] = $token;
$postfields['client_id'] = CLIENT_ID;
$postfields['client_secret'] = CLIENT_SECRET;
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields );
echo $ret = curl_exec($ch); //
查看API文檔。 grant_type
應該包含授權碼。
https://developers.pandadoc.com
http://tools.ietf.org/html/rfc6749
編輯:
grant_type應該與您的代碼中顯示的相同,即文字字符串“ refresh_token”。
如發現的那樣,刪除內容類型標題,以便正確發送post字段。
在該令牌字段中,您要傳遞哪個值。 它應該包含以前獲得的刷新令牌,而不是訪問令牌。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.