10

How do I perform a logout from my application only (not from the instagram account - but yes from my app) ?

I saw some people saying "refer the user to the instagram logout page" but it's not what I really need.

Anthony
  • 12,177
  • 9
  • 69
  • 105
Avni Yayin
  • 469
  • 1
  • 8
  • 18

4 Answers4

8

You could use an iframe in your own "logout" page. Something like:

<iframe src="https://instagram.com/accounts/logout/" width="0" height="0" />

You probably want to redirect to the main page after the log out is performed.

Hope that helped.

baek
  • 425
  • 3
  • 7
  • I try it but this error is thrown https://www.instagram.com/accounts/logout/ in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN' – dev verma Jun 15 '17 at 12:46
7

If Bhavik S's answer didn't work for you, like me, because of XFrame Options being set to SAMEORIGIN, try putting the logout in an image's src:

<img src="http://instagram.com/accounts/logout/" width="0" height="0" />
Tristan
  • 413
  • 1
  • 6
  • 10
6

If you are using PHP/HTML I would put a hidden IMG element with the SRC attribute pointed at the Instagram logout URL.

Brad
  • 195
  • 2
  • 11
-1

You can use an ajax call, which gives you another benefit that in case of an HTTP error due to any reason you'll get exception and you can find either it was logged out or you got any http error. Also in case of success you can run some code to show or hide any component on your page without any page refresh.

        $.ajax({
            url: "https://instagram.com/accounts/logout/",
            success: function (data) {
            },
            error: function (e) {
                alert('Error::' + e.responseText);
                //in case of any error you can put some code here.
            }
        });
Salik
  • 458
  • 7
  • 14