Identity Server 4/nativescript挂起 [英] Identity Server 4/nativescript Hangs

查看:114
本文介绍了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记录的邮件.

I am using native-script to build an android app that can log in with Identity Server 4. What currently happens is that I make a request to IS4 by opening a browser and using all the correct OpenID configuration and I end up on the login screen which then I choose to login with Google. Once on google, I enter my email and password and its all good and then Google tries to send me back to my site but it just hangs... Its a white page with nothing loaded and its just sits there forever, there are no error messages logged by is4 as far as I can tell.

以上本机脚本的登录部分来自OAutho2库 https://www.npmjs.com/包/nativescript-oauth2

The login part above for nativescript is from OAutho2 library https://www.npmjs.com/package/nativescript-oauth2

我试图理解这是IS4还是本机Android应用程序上的问题.页面是否挂起,因为它正在等待android应用程序接管登录工作? Mabye问题出在RedirectURI方案上吗?

I'm trying to understand would this be a problem on the IS4 or the native Android application. Is the page hanging because it is waiting on the android application to take over having the login have worked? Mabye the problem is with the RedirectURI Scheme?

其挂起的URL如下:

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

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

Since I'm running this on the actual server, I can't debug it directly, however, I did add logs to see how far the code goes. My logs tell me that the user was logged in by google and my system and my logs also show that ExternalCallback has redirected the page to

/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

/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,以帮助进行测试.

Please note that we changed RedirectUri to com.mysite.nativeapp to help with testing.

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

Lastly, I'm not sure if it matters, but we are not using https as this is still development phase.

推荐答案

仅找到示例应用

步骤01

我们将打开一个运行窗口

just finsed the sample app

Step 01

We will open a Run window

在键盘上按

Windoes Key + R

等待

我们将打开一个cmd窗口

We will open a cmd Window

在运行"窗口中,输入文字

On the Run window text-Input write

cmd

在键盘上按

Enter

步骤03

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

Step 03

We will make a directory and make it the working directory for our cmd

在CMD窗口中写

mkdir D:\Experiments\E.IDser.NativeScript

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

步骤04

我们将克隆示例项目

Step 04

We will make a clone the sample project

在CMD窗口中写

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

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

步骤05

现在将运行应用程序

Step 05

Now will run the apps

在CMD窗口中写

Start.bat

步骤06

使用方法

Step 06

how to use

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注册自定义网址方案

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

您也可以尝试

 tns debug android


Errrr 无法访问此网站

Identity Server和本机脚本之间的

通信

  • 运行


    Erorr This site cannot be reached

    communication between Identity Server and Native-Script

    • run

      nativescript-client-and-identity-server-sample/Start.bat
      

    • 请勿运行

    • do not run run

      "nativescript-client-and-identity-server-sample/identity-server/Start.bat"
      "nativescript-client-and-identity-server-sample/nativescript-client/Start.bat"
      

    • 本机脚本应用程序应在android模拟器中运行

    • native script app should run in in android emulator

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

      identity server should be run in local machine at port 5010

      在您的窗口浏览器中检查可以打开

      check in your windows browser you can open

      http://localhost:5010
      

    • 如果是

    • if yes

      在您的** android仿真器**浏览器中检查是否可以打开

      check in your **android emulator ** browser you can open

      http://10.0.2.2:5010
      

    • 10.0.2.2是什么?

    • what is 10.0.2.2 ?

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

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

    • can i change where my host 10.0.2.2 ?

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

      open 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 更改为您的网址

    • change http://10.0.2.2:5010 to your web address

      这篇关于Identity Server 4/nativescript挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆