api - 使用两因素身份验证的 instagram api 登录
问题描述
我在我的应用程序中使用Instagram API进行身份验证。API 工作正常,但是当用户使用双重身份验证时,redirect_uri 不起作用并且用户重定向到 Instagram 主页而不是正确的 URL(我的应用程序登录 URL)。我不知道我应该如何处理这个问题,也找不到任何好的答案。请帮我
注意:这种情况是第一次发生,并且当 Instagram 的登录会话在正确登录的浏览器中可用时。
解决方案
不确定这是否仍然有帮助。但是我在 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 并将用户发送到“授权”页面。根据您的实施平台,您可以应用与上述类似的内容。
推荐阅读
- elasticsearch - 如何将pdf文件导入弹性搜索
- python-3.x - Tornado websocket 客户端:如何异步 on_message?(从未等待协程)
- python - 如何将列表转换为 numpy 数组
- algorithm - MapReduce 用于聚类两个袋子中的红色和蓝色球
- python - 如何加快包含 sql 查询的代码?
- r - 如何使用R检测一列字符中的模式和频率?
- google-colaboratory - 我无法连接到 google collab
- excel - 将不同的工作表合并到一个主 Excel 工作表中
- mysql - 如何从具有自连接的子查询中获取数据?
- google-chrome - 将 PWA 添加到主屏幕无法在 chrome 移动设备上运行