我正在将我的角度应用程序与Instagram集成。
为了与instagram集成,根据instagram开发人员api https://www.instagram.com/developer/authentication/,我按照以下3个步骤进行操作
第一步:将您的用户定向到我们的授权URL
https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code
第二步:从Instagram接收重定向
http://your-redirect-uri?code=CODE
第三步:请求access_token
然后,我将在上一步中收到的代码交换为访问令牌。
curl -F 'client_id=CLIENT_ID' \
-F 'client_secret=CLIENT_SECRET' \
-F 'grant_type=authorization_code' \
-F 'redirect_uri=AUTHORIZATION_REDIRECT_URI' \
-F 'code=CODE' \
https://api.instagram.com/oauth/access_token
如果用户未登录其他窗口,则上述步骤可以正常工作。但是,如果用户已经在其他窗口中使用instagram登录,
然后步骤3有时或有时会给我以下错误
{"error_type"=>"OAuthException", "error_message"=>"Matching code was not found or was already used.", "code"=>400}
我有什么想念的吗?
在允许用户登录之前,通过在隐藏的iframe中打开instagram登出URL来执行instagram登出,如下所示:
$(document).append('<div style="display:none"><iframe src="https://instagram.com/accounts/logout/" width="0" height="0"></iframe></div>');
这将注销instagram
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句