Identity Server 4/nativescript Hangs
Asked 07 September, 2021
Viewed 1.3K times
  • 63
Votes

I have the following client:

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
}

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.

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

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?

The URL it hangs on is as follows:


  

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

EDIT:

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

At this point, the page hangs.

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

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

3 Answer