Instagram API访问令牌请求JavaScript
您好,我试图使用 Instagram API 获得连接令牌。我首先在Postman上进行了测试,这就是我所做的: 我使用此链接将请求帖子发布到Instagram API:
https://api.instagram.com/oauth/access_token?client_id=clientId=clientId&client_secret = secret = clientsecret=clientsecret&am /& code = thecode
api给我一个错误:缺少必需字段client_id
,
但是当我将内容类型设置为 xwww-form-urlencoded 一切都在邮递员身上效果很好。
因此,我尝试使用节点模块请求在JavaScript中做同样的事情。我试图用模块做与邮递员一样的事情,但它行不通...这是我的代码:
request(`https://api.instagram.com/oauth/access_token?client_id=clientid&client_secret=clientsecret&grant_type=authorization_code&redirect_uri=https://mysite/&code=` + code, {
method: 'POST',
headers: {"Content-Type": "x-www-form-urlencoded"}
}, (error, response, body) => {
console.log('body:', body)
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据MDN,内容类型应为
application/x-www-form-urlenCoded
更新:
您应该读取节点文档: https://nodejs.dev/nodejs.dev/learn/making -http-requests-with-nodejs
获取方法:
帖子方法:
As per MDN, the content type should be
application/x-www-form-urlencoded
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
Update:
You should read the node doc : https://nodejs.dev/learn/making-http-requests-with-nodejs
Get method:
Post method: