我在角色应用程序中与Instagram集成。
要与Instagram集成,我根据Instagram开发者api https://www.instagram.com/developer/authentication/
按照以下3个步骤操作第一步:将用户定向到我们的授权网址
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}
我有什么遗失的吗?
答案 0 :(得分:1)
在允许用户登录之前,通过在隐藏的iframe中打开instagram注销网址来执行instagram注销,如下所示:
$(document).append('<div style="display:none"><iframe src="https://instagram.com/accounts/logout/" width="0" height="0"></iframe></div>');
这将注销Instagram