首页 > 解决方案 > 使用两因素身份验证的 instagram api 登录

问题描述

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

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

标签: apiinstagraminstagram-apitwo-factor-authentication

解决方案


不确定这是否仍然有帮助。但是我在 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 并将用户发送到“授权”页面。根据您的实施平台,您可以应用与上述类似的内容。


推荐阅读