【发布时间】:2015-05-24 05:57:37
【问题描述】:
我正在使用 Asana API,在进行 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."
}
【问题讨论】:
-
你应该发布你正在使用的代码和你收到的错误。
-
这是我正在使用的代码 ---> $.ajax( { url : app.asana.com/-/oauth_token, dataType : 'jsonp', method: 'POST', beforeSend: function (xhr) { xhr.setRequestHeader("Authorization", "Bearer"+accessToken); }, 成功: function(result) {}, error: function(jqXHR, textStatus, errorThrown){} });错误是 { "error": "unsupported_grant_type", "error_uri": "asana.com/developers/documentation/getting-started/…", "error_description": "支持的授权类型是
authorization_code和refresh_token。" } -
你是如何设置post参数的?看起来你不是在发送它们。
标签: javascript ajax asana