React JS Cors -Origin -Instagram基本显示API
我对 cors有问题:访问控制
尝试从Instagram API交换代码以访问代码时。
Instagram api文档步骤5: https://developers.facebook.com/docs/instagram-basic-display-api-api/getting-started#step-5--xchange-change-change-change-change-change-code-for-a-token < /a>
身体参数:
const body = {
'client_id': 'xxxxxxxxxxxxxx',
'client_secret': 'xxxxxxxxxxxxxx',
'grant_type': 'authorization_code',
'redirect_uri': 'https://localhost:3000/',
'code': instaCode
};
我的请求:
axios.post(`https://api.instagram.com/oauth/access_token`, qs.stringify(body), {
headers: {'content-type': 'application/x-www-form-urlencoded'}
});
码在2个月前工作。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:您可以尝试此 axios post post request以发送表单数据首先这似乎更好,下面对我有用
,尽管您必须以表格数据发送身体。
我相信Fetch API会起作用,但是自节点17以来就可以使用,如果您使用的是较早版本,这对我有用。
来源
npm我要求
当然可以在尝试/捕获中使用它
edit: you can try this axios post request to send form data first which seems better, below worked for me though
That won't work, you have to send the body in a form data.
I believe fetch API would work but that's available since node 17, if you're using earlier version this is what worked for me.
SOURCE https://www.section.io/engineering-education/integrating-instagram-basic-display-api/
npm i request
and use that inside a try/catch of course
我浪费了3天的错误,但终于找到了解决方案。
您无法从前端侧处理它,因为Instagram API仅接受一种媒介的请求,为此,您必须在后端部署API才能解决此问题。
一旦您将API部署在后端,后端将要求访问访问权限,您的问题将得到解决。
I have wasted 3 days on this error but finally got the solution.
You cannot handle it from front-end side because Instagram API only accepts requests from one medium and for that you will have to deploy your API at backend to resolve this issue.
Once you will deploy the API at backend and backend will request for the access_token , your issue will be resolved.