Identity Server 4 / nativescript挂起

博扬

我有以下客户:

new Client
{
    ClientId = "nativeapptest",
    ClientName = "Native App Test",
    Enabled = true,
    RequireClientSecret = false,
    AllowedGrantTypes = GrantTypes.Code,
    RedirectUris = { "com.mysite.nativeapp.12365789785256-buv2dwer7jjjjv5fckasdftn367psbrlb:/home" },
    AllowedScopes =
    {
        IdentityServerConstants.StandardScopes.OpenId,
        IdentityServerConstants.StandardScopes.Profile,
        "MyScope"
    },
    RequirePkce = false,
    AllowOfflineAccess = true,
    RequireConsent = false
}

我正在使用本机脚本构建可以使用Identity Server 4登录的android应用。当前发生的情况是,我通过打开浏览器并使用所有正确的OpenID配置向IS4发出请求,最终出现在登录屏幕上然后,我选择使用Google登录。进入Google后,我输入了我的电子邮件和密码,并且一切正常,然后Google尝试将我发送回我的网站,但是它挂起了...它的白页没有加载任何内容,并且永远存在,没有任何错误据我所知,is4记录的消息。

上面的nativescript登录部分来自OAutho2库https://www.npmjs.com/package/nativescript-oauth2

我想了解这是IS4还是本机Android应用程序上的问题。页面是否挂起是因为它正在等待android应用程序接管登录工作?Mabye问题出在RedirectURI Scheme上吗?

它挂起的URL如下:

http://login.mysite.com/connect/authorize?client_id=nativeapptest&response_type=code&redirect_uri=com.mysite.nativeapp.12365789785256-buv2dwer7jjjjv5fckasdftn367psbrlb%3A%2Fhome&scope=openid%20profile%20MySite&response

编辑:

由于我是在实际的服务器上运行该程序,因此无法直接对其进行调试,但是我确实添加了日志以查看代码的执行范围。我的日志告诉我用户已通过Google和系统登录,并且我的日志还显示ExternalCallback已将页面重定向至

/connect/authorize/callback?client_id=nativeapptest&response_type=code&redirect_uri=com.mysite.nativeapp%3A%2F%2Fhome&scope=openid%20profile%20MyScope&response_mode=query&state=abcd

此时,页面挂起。

请注意,我们已将RedirectUri更改为com.mysite.nativeapp以帮助进行测试。

最后,我不确定这是否重要,但是我们仍未使用https,因为这仍处于开发阶段。

穆罕默德·拉拉希德(Mohamed Elrashid)

刚刚找到示例应用程序

步骤01

我们将打开一个运行窗口

在键盘上按

Windoes Key + R

等待

步骤02

我们将打开一个cmd窗口

在“运行”窗口中,输入文字

cmd

在Keybord印刷机上

Enter

步骤03

我们将创建一个目录并将其作为cmd的工作目录

在CMD窗口中写

mkdir D:\Experiments\E.IDser.NativeScript

cd /d D:\Experiments\E.IDser.NativeScript

步骤04

我们将克隆一个样本项目

在CMD窗口中写

git clone https://github.com/Elrashid/nativescript-client-and-identity-server-sample.git

cd nativescript-client-and-identity-server-sample

步骤05

现在将运行应用

在CMD窗口中写

Start.bat

步骤06

如何使用

在此处输入图片说明 在此处输入图片说明 在此处输入图片说明

在此处输入图片说明 在此处输入图片说明 在此处输入图片说明

为什么

1    app
              +---+
                  |
     identity     |
2    server       |
                  |
                  |
                  |
3    google       +-+   user
                  |     intractiom
                  |
                  |       your
     identity     |       app
4    server       | <---+ stop
              +---+       here

5     app     +---+
                  |
                  |
                  |
     identity     +--+  background
6    server       |
                  |
                  |
7     app         |
               +--+

请参阅注册Android的自定义URL方案

<data 
android:path="/home"
android:scheme="com.mysite.nativeapp
            .12365789785256-buv2dwer7
            jjjjv5fckasdftn367psbrlb"
/>

你也可以尝试

 tns debug android

Erorr无法访问此站点

Identity Server与本机脚本之间的通信

  • nativescript-client-and-identity-server-sample/Start.bat
    
  • 不要跑

    "nativescript-client-and-identity-server-sample/identity-server/Start.bat"
    "nativescript-client-and-identity-server-sample/nativescript-client/Start.bat"
    
  • 本机脚本应用程序应在android模拟器中运行

    在此处输入图片说明

  • 身份服务器应在本地计算机上的端口5010上运行

  • Windows浏览器中签入即可打开

    http://localhost:5010
    
  • 如是

  • 在** Android模拟器**浏览器中签入即可打开

    http://10.0.2.2:5010
    
  • 10.0.2.2是什么?

    android模拟器主机回送接口的特殊别名

  • 我可以更改主机10.0.2.2的位置吗?

    打开nativescript-client \ app \ my-oauth-provider.ts

        public authority = "http://10.0.2.2:5010";
        public tokenEndpointBase = "http://10.0.2.2:5010";
        public cookieDomains = ["10.0.2.2:5010"];
    
  • http://10.0.2.2:5010更改为您的网址

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章