我正在使用Asana API,在進行API調用以獲取新的刷新令牌時遇到問題,請讓我知道我錯在哪裏。使用AJAX的Asana API集成
我正在通過Javascript AJAX進行API調用。
app.asana.com/-/oauth_token (POST request)
POST參數
{
"grant_type":"refresh_token",
"client_id":"",
"client_secret":"",
"redirect_uri":"",
"refresh_token":""
}
這是我使用的代碼:
$.ajax({
url : app.asana.com/-/oauth_token,
dataType : 'jsonp',
method: 'POST',
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Bearer " + accessToken);
},
success : function(result) {},
error: function(jqXHR, textStatus, errorThrown){}
});
我收到返回的錯誤是:
{
"error": "unsupported_grant_type",
"error_uri": "asana.com/developers/documentation/getting-started/…;,
"error_description": "The supported grant types are authorization_code and refresh_token."
}
您應該發佈您正在使用的代碼和您收到的錯誤。 – McWayWeb
這是我使用---> $。阿賈克斯({ \t \t URL代碼:app.asana.com/-/oauth_token, \t \t數據類型: 'JSONP', \t \t方法: 'POST', \t \t beforeSend:function(xhr){ \t \t xhr。setRequestHeader(「Authorization」,「Bearer」+ accessToken); \t \t}, \t \t成功:功能(結果){}, \t \t \t錯誤:功能(jqXHR,textStatus,errorThrown){} \t \t});錯誤是「error」:「unsupported_grant_type」, 「error_uri」:「https://asana.com/developers/documentation/getting-started/authentication」, 「error_description」:「支持的授權類型是authorization_code '和'refresh_token'「。 } –
你如何設置發佈參數?看起來你並沒有發送它們。 –