-
Notifications
You must be signed in to change notification settings - Fork 201
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
Webauth not returning to app when using React Native Navigation #83
Comments
Seems like this problem doesn't limit to Google login |
I think I found the problem, seems like the The process is like following:
It will register the linking event handler between step 1 and 2. And there are two callbacks will be triggered after landing back the app:
And you can see in the @Override
public void onHostResume() {
if (this.callback != null) { // because callback hasn't been cleared
final WritableMap error = Arguments.createMap();
error.putString("error", "a0.session.user_cancelled");
error.putString("error_description", "User cancelled the Auth");
this.callback.invoke(error);
this.callback = null;
}
} // this callback will be triggered with err
NativeModules.A0Auth0.showUrl(url, closeOnLoad, (err) => {
Linking.removeEventListener('url', urlHandler);
if (err) {
reject(err);
} else if (closeOnLoad) {
resolve();
}
}); and within this callback, it will remove the deep link event handler. This is a race condition, if the I can modify it to make it somehow act as it works:
For the former modification, it is an incomplete solution, we should have a correct way to clear the And for the later modification, it seems like the CustomTabsIntent won't close itself. And because of that, the app will stay in inactive state, and cannot receive the linking event. I'm not sure whether it is related to this #47 |
Here is a little more information about the package versions: react-native: 0.42.3 |
Great ! Can you make some gist for the temporary fix ? |
@madbean Thanks, but I don't think the method I used can be qualified as a valid temporary fix. Still waiting the project owner's opinion |
@rayshih I'm having a similar problem currently if I close the tab manually after login, I get user cancelled auth error (even though the login is successful). I've managed to get the deep link to close the custom tab by adding:
before However the problem of the The only way I can get it to login is by removing the |
@renrizzolo Cool! What if we add some delay for the |
@rayshih @renrizzolo I just tried a Google connection Login with the Sample Project. https://github.com/auth0-samples/auth0-react-native-sample Please can you try the the sample and see if you can recreate the issue and provide steps to do so. Thx |
@rayshih I have zero Java experience but this hack is working for me!
@cocojoe I am doing some investigation with the example app, I have boiled it down to react-native-navigation (I already suspected this as this started happening after I switched to that from react-navigation). I added RNN to the example project and the custom tab does not close. @rayshih are you using RNN also? RNN has you extend I'm not sure if this is of any help but this is the main NavigationActivity: There's also IntentDataHandler.java |
@renrizzolo Cool!! Yes, I use RNN, too Sounds like we found the exact cause of this issue. It indeed is a race condition. And I think the solution provided by @renrizzolo is ok. Not sure whether there is a better way |
@rayshih ahh, there we go. @cocojoe FYI fork of example app with RNN added here https://github.com/renrizzolo/auth0-react-native-sample |
@renrizzolo thanks for your example, I added iOS support to it and just to confirm that works fine. (I need to check both platforms) My test setup is using Emulator - Nexus 5X API 23. I am unable to use the Google connection, I am thrown back with The close tabs appear to be an issue in general and is raised/confirmed in #87 I'm not an Android guy so let me discuss this internally, Thx. |
Hi @cocojoe, thanks for your help on this OK I tried with Nexus 5X API 23, seems that because it opens in the external browser it will return to the app (but still has the race condition with the callback). The delay added to Also worth noting that #90 does not fix the custom tab closing for this react-native-navigation version, I also need to add And to clarify, this issue is for any auth (not just google) despite the title. |
Hey guys, I've forked and added some hotfix here. Would you mind that I create a PR? |
@rayshih PRs are always encourage, so please do. There are enough people in this thread to help test. Thx |
@rayshih @renrizzolo please confirm no issues now with react-native-navigation and react-native-auth0 1.2.1? It would be great if you could help both confirm the version of react-native and react-native-navigation you are using along with your test setup e.g. API version, browser used. Thanks |
@cocojoe just tested and working with my setup of react-native@0.48.4 and react-native-navigation@1.1.236 |
the fix suggested by @renrizzolo is not working for me on real Android device. Auth0 is opened in an external browser and there is an endless progress bar. if I manually close the app and reopen it, I can see that I'm logged-in, meaning, Auth0 call was OK but the navigation back to the app is broken. I also tried to increase the delay in the workaround code from 100ms to 1000ms and 5000 ms without any success. Any idea how to fix that? |
No idea without more information, the first step in any issue is being able reproduce it. Please open a new issue and provide a simple reproducible project forked from the sample login. https://auth0.com/docs/quickstart/native/react-native What version of Android SDK, what browser/version etc Thanks |
The problem still persist in 1.2.1 :/ |
@davidroman0O My advice is the same as my last post. I can investigate but I need a reproducible sample and specifics to replicate your own testing environment. Thanks |
Hi Guys, Also ran into this issue and have not been able to fix it. Tested on the fork from @renrizzolo with latest react-native-navigation (v.1.1.407) and latest react-native-auth0 (v.1.2.2). As reported, after login the page will stay in loading mode and never return to the app. @renrizzolo did you manage to get past this issue, or can anyone else chip in? All help is really appreciated! |
@kristiansorens @cocojoe this PR is the cause #126 Putting
back in at Line 63 will fix the problem with not returning to the app after logging in. I guess this conflicts with the problems described in #124 (needing to switch to another app to copy verification code) - I'm not sure if / how we can satisfy both. With the above fix, the Sign In tab will always be in the recent apps stack, even after logging in. (maybe this is already the case for the current version of the lib). |
@lbalmaceda can you have a look at this please. |
@renrizzolo tried your fix above, but I still experience the same. Do you have a working example with RNN and Auth0 that i can have a look at? |
@kristiansorens I just tested with https://github.com/renrizzolo/auth0-react-native-sample (upgraded to react-native-auth0@1.2.2 and react-native-navigation@1.1.407) and it works after adding the Are you sure everything is right in your AndroidManifest.xml? e.g launch mode and Intent filter. |
@renrizzolo I think that's because of how |
@lbalmaceda I see. Apologies as I'm not really familiar with java or android dev. |
I don't think so, at least not generically since adding that modification will force users that are not using |
@lbalmaceda No worries, I understand. Thanks! |
It can open the login page, and I can log in with my google account, which can be confirmed by checking the dashboard.
However, after the google login, it will stop there. Won't redirect/close the login screen.
I've used "Deep Link Tester" to confirm that the intent filter works.
The text was updated successfully, but these errors were encountered: