question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Authorize never returns after async call

See original GitHub issue

Issue

I have been trying to implement a solution where the “Reset Password” option is handled when a user is attempting to authorize with my app. I came up with the below, but when this executes the authorize call never returns. It doesn’t return with a success or error. I have also noticed this will randomly happen during development when I’m reloading the app several times. It will enter my auth function and never return, thus hanging until I clear cache, clear data and restart the app.

export const auth = () => {
    return async(dispatch) => {
        var resetEndpoint = "https://login.microsoftonline.com/giftwizit.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_secretreset1"
        dispatch(authStart())
        try {
            console.log("in auth function");
            const authState = await authorize(authCfg.config);
            // Store token info in asyncStorage
            dispatch(authStoreToken(authState));
        }catch(error) {
            // dispatch(authFail(error));
            if(error.message.indexOf("AADB2C90118") !== -1){
               await authorize({
                   ...authCfg.config,
                   serviceConfiguration:{
                       ...authCfg.config.serviceConfiguration,
                       authorizationEndpoint: resetEndpoint
                   }
               }).then((result) => {
                   console.log(result);
               }).catch((e) => {
                   console.log(e);
               });
               console.log("Password reset complete");
            }else {
                console.log(error);
            }
        }
    }
}

Environment

  • Your Identity Provider: e.g. IdentityServer 4 / Okta / Azure Azure

  • Platform that you’re experiencing the issue on: iOS / Android / both Android

  • Are you using Expo? No

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

26reactions
isnifercommented, Feb 3, 2020

Same here

UPD (2hrs ago + 1 iOS Developer): I have fixed my case:

  1. Azure AD will give you a returnUrl like msauth.[BUNDLE_ID]://auth
  2. It’s IMPORTANT to ADD SLASH AT THE END in your config: msauth.[BUNDLE_ID]://auth/
  3. Then it will works.

The problem code is here — https://github.com/openid/AppAuth-iOS/blob/master/Source/OIDAuthorizationService.m#L125 This method on line — https://github.com/openid/AppAuth-iOS/blob/master/Source/OIDAuthorizationService.m#L111 returns false.

You’re welcome.

5reactions
jdeggercommented, Apr 28, 2020

Even though this issue is aimed at Android, we noticed that the iOS solution provided by @isnifer is fixing both our iOS and Android-issues for us.

Normal Microsoft accounts use a redirect URI without a trailing slash Azure AD accounts use a redirect URI including a trailing slash

Both, however, work with the trailing slash. We have updated our configuration to add the trailing slash and now both Android and iOS workperfectly.

Thanks @isnifer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to return the value while using async function in nodejs
You must return a Promise from your getGoogleApiToken . One such way is to wrap a Promise around the jwtClient.authorize call - async...
Read more >
Use Promise.all to Stop Async/Await from Blocking Execution ...
Fetch sends off a request to the Dog CEO REST API and waits for a response. Once the response comes back, it resolves...
Read more >
Authorization Callback Never Returns. C# - Windows
I am testing the library via a c# console application. The problem is that the authorization return callback never gets called (I confirmed...
Read more >
Async iteration and generators - The Modern JavaScript Tutorial
To iterate, we use for await(let value of range) (4) , namely add “await” after “for”. It calls range[Symbol.asyncIterator]() once, and then its ......
Read more >
Function node return doesnt await? - Questions - n8n community
Hello I have a script function that need to return a request ... I have tried moving the return inside the async await...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found