【发布时间】:2017-04-25 15:05:05
【问题描述】:
用于验证用户身份并为他们提供会话访问令牌的 instagram“服务器端工作流程”不起作用。第一部分的工作原理是我可以从这里获取代码: https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code
但是,当将此代码发布到 https://api.instagram.com/oauth/access_token 为了获得访问令牌,它只响应“您必须提供客户 ID”,即使我已将其作为表单数据的一部分提供 - 与我最初用于获取代码的客户 ID 相同!
这是我正在使用的代码:
getIgToken: function (igCode) {
let data = {
client_id: config.imported.instagram.client_id,
client_secret: config.imported.instagram.client_secret,
grant_type: 'authorization_code',
redirect_uri: 'http://localhost:5000/app/scrape',
code: igCode
}
return $http({
method: 'POST',
url: 'https://api.instagram.com/oauth/access_token',
data: data,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
})
}
显然其他人报告了将数据发布为 json 的问题,然后通过使用“application/x-www-form-urlencoded”解决了这些问题 - 但是现在这似乎也不起作用。
这是返回的确切错误消息:
{error_type: "OAuthException", code: 400, error_message: "You must provide a
client_id"}
code:400
error_message:"You must provide a client_id"
error_type:"OAuthException"
【问题讨论】:
标签: javascript angularjs authentication oauth instagram