Instagram API: force prompt during authentication

痴心易碎 提交于 2019-12-05 00:33:36

I believe that the most simple way is to use next url:

https://instagram.com/accounts/logoutin/?force_classic_login=&next=URLENCODED_INSTAGRAM_OAUTH_URI_PATH_WITH_YOUR_DATA

For example:

window.location.assign('https://instagram.com/accounts/logoutin/?force_classic_login=&next=' + encodeURIComponent('/oauth/authorize/?response_type=code&scope=public_content+follower_list+comments&client_id='+ YOUR_IG_CLIENT_ID + '&redirect_uri='+encodeURIComponent(YOUR_REDIRECT_URI)));

Please take a note that your redirect uri should be encoded twice

I managed to get it working:

I try loading an image with the url of the instagram logout page before opening the authorize popup.
Something like this (coffeescript):

windowOpen = ->
    window.open("/instagram/authorize?...")

if forceLogin
    tryLogout().always ->
        windowOpen()

And the tryLogout function (setTimeout 10seconds as a fallback)

tryLogout: ->
    deferred = $.Deferred()
    logOutImg = new Image()

    logOutImg.onerror = ->
        deferred.resolve()
    logOutImg.onload = ->
        deferred.resolve()

    logOutImg.src = 'https://instagram.com/accounts/logout/'

    setTimeout(->
        deferred.reject()
    , 10000)

    return deferred.promise()
Plumillon Forge

Here is the solution : you have to delete the Instagram cookie named sessionid from your browser so Instagram doesn't recognize you anymore

Solution for Android is here : https://stackoverflow.com/a/26847187/328845

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!