Search code examples
instagram-api

How to give option for switch account on Instagram API?


I am using Instagram API, user can login with their account and i can use their access token for all endpoints. Once the user logged in, in browser session exist. How to give option for user to switch between Instagram accounts.

login -> 1 account -> switch account -> because of previous session it's again login with same account without confirmation.

What is the solution for this?


Solution

  • You have logout from instagram. Opening URL "https://instagram.com/accounts/logout/" will log user out of instagram.

    You have to do this before you give this option to login again

    One way I did it on https://www.picodash.com was to open a hidden iframe with this URL and it will logout, (jquery code)

    $('#content').append('<div style="display:none"><iframe src="https://instagram.com/accounts/logout/" width="0" height="0"></iframe></div>');
    

    So when give the option to add second account, run the above code before you allow the user to click login button