[英]App not authenticating with React-Native
我正在学习React-Native并尝试进行oAuth2身份验证。 我已经使用服务和重定向uri注册了我的应用程序。 当用户单击应用程序上的“登录”按钮时,应该执行以下操作:
onLoginPressed() {
fetch("https://www.hackerschool.com/oauth/authorize?response_type=code&client_id=("+auth.client_id+")&redirect_uri=("+auth.redirect_uri+")")
.then(response => _handleResponse(response))
.catch(error =>
this.setState({
isLoading: false,
message: 'Something bad happened ' + error
}));
LinkingIOS.openURL("https://www.hackerschool.com/oauth/authorize?response_type=code&client_id=("+auth.client_id+")&redirect_uri=("+auth.redirect_uri+")");
}
但是,响应是完整的html渲染,而不是使我反弹回我的我的redirect_uri的令牌。
关于我在做什么错的任何想法吗?
要检查的一件事是Xcode正在正确搜索库头(尤其是使用LinkingIOS)。
“除了PushNotificationIOS
和LinkingIOS
之外, PushNotificationIOS
与React Native一起提供的库,此步骤不是必需的。”
LinkingIOS.openURL
函数是否应该在fetch
块中服务器响应后运行? 如果是这样,则需要将其包含在另一个then
块中。
如现在所写, LinkingIOS.openURL
将在fetch
行之后LinkingIOS.openURL
运行。 然后,当它们解析或出错时, then
和catch
fetch
块将运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.