5
votes

I'm using Instagram API for authentication in my app. the API works fine but when a user is using two-factor authentication the redirect_uri doesn't work and user redirected to the Instagram main page instead of the correct URL (my app login URL). I don't know how should I handle this and couldn't find any good answer. please help me

Note: this scenario happens for the first time and when Instagram's login session is available in browser user logged in correctly.

1
Experiencing the same issue, and this seems due to a recent change. It coincided with the redesigned login screens. Also seems there is no way to report this issue by traditional means: dropbox.com/s/m5xac5tlc6243ns/… - Harel
Did you manage to solve this? - Daniel Tovesson

1 Answers

0
votes

Not sure if this is still helpful. But I implemented the following on React Native WebView component and resolved Instagram's clear misstep.

Note - A more robust solution would be for Instagram to actually solve the bug.

As props on WebView:


          source={{ uri: this.state.uri  }}
          onNavigationStateChange={this._onNavigationStateChange}

The handling method:

 _onNavigationStateChange(webViewState){
    const url = webViewState.url || ''
    if(url.includes('challenge')){
      this.setState({challenged: true})
    }
    if(url === 'https://www.instagram.com/' && this.state.challenged){
      this.setState({
        uri: `${URI}&indifferent_query_param=${(new Date).getTime()}`
      })
    }
  }

The handling method forces rerender of WebView and sends the user to the "authorize" page. Depending on your platform of implementation, you could apply something similar to the above.