title: Instagram Basic Display API OAuth error: code 400, invalid_redirect_uri
body: <p>I want to connect Instagram Basic Display API with a website in order to display one user's post. But, when trying to authenticate the user (myself, for test purposes) I'm getting this error:</p>
  
  <pre><code>{"error_type": "OAuthException", "code": 400, "error_message": "Invalid redirect_uri"}
  </code></pre>
  
  <p>This is the PHP code I'm using for my request:</p>
  
  <pre><code>require_once 'ig_defines.php';
  
  Class instagram_basic_display_api {
  
      private $_appId = INSTAGRAM_APP_ID;
      private $_appSecret = INSTAGRAM_APP_SECRET;
      private $_redirectUrl = INSTAGRAM_APP_REDIRECT_URI;
      private $_getCode = '';
      private $_apiBaseUrl = 'https://api.instagram.com/';
  
      public $authorizationUrl = '';
  
      // called on class init
      function __construct( $params ) {
  
          // save instagram code
          $this-&gt;_getCode = $params['get_code'];
  
          // get an access token (code will follow)
  
          // get authorization url
          $this-&gt;_setAuthorizationUrl();
      } 
  
      private function _setAuthorizationUrl() {
          $getVars = array(
              'app_id' =&gt; $this-&gt;_appId,
              'redirect_uri' =&gt; $this-&gt;_redirectUrl,
              'scope' =&gt; 'user_profile,user_media',
              'response_type' =&gt; 'code'
          );
          // create url
          $this-&gt;authorizationUrl = $this-&gt;_apiBaseUrl . 'oauth/authorize?' . http_build_query( $getVars );
      }
  }
  </code></pre>
  
  <p><code>private $_redirectUrl = INSTAGRAM_APP_REDIRECT_URI;</code> is <code>"http://google.com/"</code> as suggested <a href="https://stackoverflow.com/questions/60374528/invalid-redirect-uri-for-instagram-login-using-react-native">in this post</a>. My OAuth Redirect URI in the facebook developer tools Instagram API settings is <code>"http://google.com/"</code> as well.</p>
  
  <p>For testing I'm using my test webspace. The URL is something like <code>http://mytestwebspace.de/instagram/news_ig_test.php</code>. As you can see, it doesn't have SSL. The final page is going to, though. Could the lack of SSL be an issue? </p>
  
  <p>EDIT: I forgot to add, I did try using <code>http://mytestwebspace.de/instagram/news_ig_test.php</code> as redirectUrl before, but I'm still getting the same error.</p>
  
  <p>I'm not sure what the reason could be.</p>