instagram api登录使用双因素身份验证

时间:2018-06-18 12:31:36

标签: api instagram instagram-api two-factor-authentication

我在我的应用中使用Instagram API进行身份验证。 API工作正常,但当用户使用双因素身份验证时,redirect_uri不起作用,用户重定向到Instagram主页而不是正确的URL(我的应用程序登录URL)。我不知道如何处理这个问题并且找不到任何好的答案。请帮帮我

注意:这种情况是第一次发生,并且正确登录的浏览器用户可以使用Instagram的登录会话。

1 个答案:

答案 0 :(得分:0)

不确定这是否仍然有用。但是我在React Native WebView组件上实现了以下内容,并解决了Instagram明显的失误。

注意-一个更强大的解决方案是让Instagram实际解决该错误。

作为WebView上的道具:


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

处理方法:

 _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()}`
      })
    }
  }

该处理方法强制重新渲染WebView,并将用户发送到“授权”页面。根据您的实现平台,您可以应用与上述类似的内容。

相关问题