Authorize never returns after async call
See original GitHub issueIssue
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:
- Created 4 years ago
- Reactions:4
- Comments:14 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same here
UPD (2hrs ago + 1 iOS Developer): I have fixed my case:
msauth.[BUNDLE_ID]://auth
msauth.[BUNDLE_ID]://auth/
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.
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.