Identity Server 4/nativescript挂起

Boj*_*jan 8 c# asp.net-core-mvc nativescript identityserver4

我有以下客户:

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
}
Run Code Online (Sandbox Code Playgroud)

我使用本机脚本构建一个可以使用Identity Server 4登录的Android应用程序.目前发生的是我通过打开浏览器并使用所有正确的OpenID配置向IS4发出请求,最后我在登录屏幕上然后我选择使用Google登录.一旦进入谷歌,我输入我的电子邮件和密码,它一切都很好,然后谷歌试图将我送回我的网站,但它只是挂起...它的白页没有任何加载,它只是永远坐在那里,没有错误据我所知,is4记录的消息.

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

我试图理解这是IS4或原生Android应用程序的问题.页面是否挂起,因为它正在等待Android应用程序接管登录有效?Mabye问题在于RedirectURI计划?

它挂起的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_mode=query&st

编辑:

由于我在实际的服务器上运行它,我无法直接调试它,但是,我确实添加了日志以查看代码的进度.我的日志告诉我用户已经通过谷歌和我的系统登录,我的日志也显示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,因为这仍然是开发阶段.

Moh*_*hid 5

刚刚找到示例应用程序

步骤01

我们将打开一个运行窗口

在键盘上按

Windoes Key + R
Run Code Online (Sandbox Code Playgroud)

等待

步骤02

我们将打开一个cmd窗口

在运行窗口中输入文本

cmd
Run Code Online (Sandbox Code Playgroud)

在Keybord印刷机上

Enter
Run Code Online (Sandbox Code Playgroud)

步骤03

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

在CMD窗口中写

mkdir D:\Experiments\E.IDser.NativeScript

cd /d D:\Experiments\E.IDser.NativeScript
Run Code Online (Sandbox Code Playgroud)

步骤04

我们将克隆一个样本项目

在CMD窗口中写

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

cd nativescript-client-and-identity-server-sample
Run Code Online (Sandbox Code Playgroud)

步骤05

现在将运行应用

在CMD窗口中写

Start.bat
Run Code Online (Sandbox Code Playgroud)

步骤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         |
               +--+
Run Code Online (Sandbox Code Playgroud)

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

<data 
android:path="/home"
android:scheme="com.mysite.nativeapp
            .12365789785256-buv2dwer7
            jjjjv5fckasdftn367psbrlb"
/>
Run Code Online (Sandbox Code Playgroud)

你也可以尝试

 tns debug android
Run Code Online (Sandbox Code Playgroud)

错误无法访问此站点

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