Search code examples
oauthinstagraminstagram-api

Instagram OAuth authorize endpoint redirects to instagram's homepage


I'm writing very simple application that uses Instagram basic display to show user's pictures uploaded to IG. However, the first step during OAuth authorization, after succesful login/authorization takes user to https://www.instagram.com/ instead of redirect_uri specified in GET parameter of request.

I followed the docs multiple times, tried different IG users, but without any effect.

I'm using this link to authorize user: https://api.instagram.com/oauth/authorize?client_id=my_instagram_app_id&redirect_uri=https://localhost/api/ig/proceed/&scope=user_profile,user_media&response_type=code

Application settings:

  • Settings > Basic > Website > Site URL = https://localhost/
  • Instagram basic display > Basic display > Valid OAuth Redirect URIs = https://localhost/api/ig/proceed/
  • Roles > Roles > Instagram testers = My account is added and confirmed in instagram settings.

Apache server runs at localhost and acts like reverse proxy (to provide HTTPS, as it's required for all redirect urls).

ProxyPass "/api"  "http://127.0.0.1:8080/api"
ProxyPassReverse "/api"  "http://127.0.0.1:8080/api"

I have some unrelated records in etc/hosts, but nothing affects this.

Tried this on all browsers I have - Firefox, Chrome, Edge. The weirdest thing is that it worked on FF for the first time, but no matter what I tried to do (annonymous browsing, recreate the whole app in meta devs, remove authorization from user) I wasn't able to reproduce the right behavior.

Another weird thing is that it works fine on safari browser on iPhone, however I cannot display logs or anything, so I have no idea why. And the redirection ends on localhost (which is obviously not running anything).

Authorization window shown without any problems

Redirection response from l.instagram.com contains location header pointing at instagram.com

The whole thing puzzles me gravely and I'm out of ideas why is this extremely simple use of well documented API is broken (probably just for me)


Solution

  • It was probably caused by short term issue with the Instagram authentication API itself. The problem went away after several days, now everything works flawlessly. I didn't have to take any steps to solve it.