繁体   English   中英

应用程序未通过React-Native进行身份验证

[英]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)。

“除了PushNotificationIOSLinkingIOS之外, PushNotificationIOS与React Native一起提供的库,此步骤不是必需的。”

在Xcode中链接React本机库

LinkingIOS.openURL函数是否应该在fetch块中服务器响应后运行? 如果是这样,则需要将其包含在另一个then块中。

如现在所写, LinkingIOS.openURL将在fetch行之后LinkingIOS.openURL运行。 然后,当它们解析或出错时, thencatch fetch块将运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM