2014-12-24 33 views
1

我按照和雙重檢查的步驟從https://dev.twitter.com/oauth/application-only的Twitter的oauth2 - 在獲得承載令牌錯誤

得到的承載令牌我不斷收到以下錯誤:
狀態:403禁止 {「錯誤」: [{「code」:99,「message」:「無法驗證您的憑證」,「label」:「authenticity_token_error」}]}

我嘗試在body中傳遞grant_type = client_credentials以及查詢參數。

我打的URL是:https://api.twitter.com/oauth2/token?grant_type=client_credentials

集管套裝: 授權:基本[base64encoded(client_key:client_secret)] 內容類型:應用/ X WWW的窗體-urlencoded;字符集= UTF- 8

我使用海報作爲其餘客戶端來撥打電話。

有沒有人指出我可能會出錯的地方。

非常感謝。

+0

似乎爲我使用命令行卷曲;你可以用'curl -u -X POST -H來驗證你是否擁有正確的用戶密鑰和祕密:Content-Type:application/x-www-form-urlencoded; charset = UTF -8「https://api.twitter.com/oauth2/token?grant_type = client_credentials'這應該給你一個訪問令牌 –

回答

0

發送「grant_type = client_credentials」作爲有效負載。

var options = { 
    "method":"post", 
    "headers": { 
     "Authorization":"Basic " + Utilities.base64Encode(param), 
     "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8" 
    }, 
    "payload" : "grant_type=client_credentials" 
    }; 

    var response = UrlFetchApp.fetch(TOKEN_URL,options); 
相關問題