Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signInSilent method randomly returns an array instead of an object #76

Open
DanielTokyo opened this issue Mar 5, 2021 · 0 comments
Open

Comments

@DanielTokyo
Copy link

DanielTokyo commented Mar 5, 2021

Hi, I've created an Android Cordova app based on an Angular 11 SPA. I am calling the signInSilent method from my SPA's HttpInterceptor to get a token to pass to my API. This usually works normally the first time, but then it starts randomly giving me an array as a response when invoked.

This is my configuration (I removed the API ID):

{
    authorities: [
      {
          type: 'AAD',
          audience: 'AzureADMyOrg',
          authorityUrl: '',
          cloudInstance: 'MSALAzurePublicCloudInstance',
          default: true
      }
    ],
    authorizationUserAgent: 'DEFAULT',
    multipleCloudsSupported: false,
    brokerRedirectUri: false,
    accountMode: 'SINGLE',
    scopes: ['api://00000000-0000-0000-0000-000000000000/access_api'],
    otherScopesToAuthorize: [
      'User.Read'
    ]
  }

Normally I get this kind of result:

{
    "token":"eyJ0eX000000...",
    "account":{
        "id":"00000000-0000-0000-0000-000000000000",
        "username":"Missing from the token response",
        "claims":[]
    }
}

But then I randomly also receive this result:

[
    {
        "id":"00000000-0000-0000-0000-000000000000",
        "username":"Missing from the token response",
        "claims":[]
    }
]

As you can see, first, it doesn't have a token; second, it is an array.

I keep my own cache of the token, so this is not a problem during the time that the token is valid, but as soon as it expires, if the next API call receives the array result, I end up passing the cached expired token to the API, and of course get a 401 Unauthorized error.

The most bizarre thing about this error is that when debugging the Java code using Android Studio, I noticed that the array result is being passed to my app's JavaScript callback, before the native code is invoked. So the native code produces the right authorization object, but it never gets to the app because the callback has already been triggered.

Has anyone experienced this error, and/or knows how I can solve it? Any ideas are welcome.

Thank you for your attention, and for this great library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant