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

react-native-auth0 WebAuth popup #124

Closed
pragadeesh0106 opened this issue Jan 22, 2018 · 20 comments · Fixed by #126
Closed

react-native-auth0 WebAuth popup #124

pragadeesh0106 opened this issue Jan 22, 2018 · 20 comments · Fixed by #126

Comments

@pragadeesh0106
Copy link

pragadeesh0106 commented Jan 22, 2018

auth0
            .webAuth
            .authorize({ 
              scope: 'openid profile offline_access', 
              audience: 'https://' + Config.auth0Domain+ '/api/v2/'
              })
            .then(function (credentials) {
                console.log(credentials);
            })
            .catch(error =>
                console.log("error", error)
            );

when this function is called the webauth is opened outside the app . So when i go check my otp and click recent tabs in my phone my app remains there but the auth0 webauth popup is missing .

If anyone knows how to solve the issue kindly help...

@cocojoe
Copy link
Member

cocojoe commented Jan 23, 2018

@pragadeesh0106 please can you tell us the steps to re-create, I presume you are using MFA.
It is expected behaviour that Web Auth is launched via your default system browser, most often Chrome. This is an industry requirement for web auth, it should not use built in browser views.

@pragadeesh0106
Copy link
Author

web view opening in the browser is not a issue .

The auth0 page opens in a chrome web view and when i go check my otp in my messenger and come back to enter otp im not able to reopen that webview it closese automatically.

@scottbrassfield
Copy link

scottbrassfield commented Jan 25, 2018

We are seeing this issue as well. When using webAuth with Passwordless authentication on Android, the user is required to navigate out of the default system browser to retrieve the code from the user's email. Upon navigating back, the browser window where the code is meant to be entered has closed, and the authentication process cannot be completed.

iOS works as expected

@cocojoe
Copy link
Member

cocojoe commented Jan 25, 2018

Thanks, I'll have a run through this.

@msalokangas
Copy link

@cocojoe in our case, we tracked the problem to be related to Chrome Custom Tabs being used in Android. Right now our workaround will be to disable Custom Tabs.

@pragadeesh0106
Copy link
Author

@cocojoe what is the workaround to disable custom tabs does anyone know it ??

@lbalmaceda
Copy link
Contributor

@pragadeesh0106 I guess in this method skip the "CustomTabsIntent" code and just start a new Intent with Action VIEW and the URL as URI, like it's done when the activity is null.

@msalokangas
Copy link

@pragadeesh0106 @lbalmaceda yes, that's what we are doing. so we forked the library and removed the CustomTabsIntent part.

@pragadeesh0106
Copy link
Author

I didn't get you can u explain clearly what to do and i am calling the auth0 from react native so should i do the changes in react native or the node modules of the react native auth0

@msalokangas
Copy link

@pragadeesh0106 you would fork react-native-auth0 library and edit your own fork. and then reference the fork from your package.json

@pragadeesh0106
Copy link
Author

After forking what is the change to be done i didn't get that part.

@lbalmaceda
Copy link
Contributor

lbalmaceda commented Jan 26, 2018

This is a workaround while we seek for a formal solution. You have to fork the repo and replace:

A0Auth0Module

        if (activity != null) {
            CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
            CustomTabsIntent customTabsIntent = builder.build();
            customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            customTabsIntent.intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            customTabsIntent.launchUrl(activity, Uri.parse(url));
        } else {
            final Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            intent.setData(Uri.parse(url));
            getReactApplicationContext().startActivity(intent);
        }

with

            final Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
            intent.setData(Uri.parse(url));
            getReactApplicationContext().startActivity(intent);

then just build and reference the library locally

@pragadeesh0106
Copy link
Author

intent.addFlags(Intent. FLAG_ACTIVITY_NEW_TASK);

Above flag needs to be added and the it worked fine thank you.

Is there any way to open it within the app instead of a browser.

@lbalmaceda
Copy link
Contributor

The only way would be through Custom Tabs as they open "in a separate activity" within your app. Use of the WebView component is blocked for OAuth requests.

@pragadeesh0106
Copy link
Author

So your saying it is not possible.

@cocojoe
Copy link
Member

cocojoe commented Jan 29, 2018

@pragadeesh0106 While technically it's possible to launch a WebView, this would be a pointless practice as OAuth authentication is not permitted using WebView.

https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html

@pragadeesh0106
Copy link
Author

OK got it

@msalokangas
Copy link

@pragadeesh0106 @cocojoe @lbalmaceda This issue should not be closed, there is no real fix for it yet

@cocojoe
Copy link
Member

cocojoe commented Jan 29, 2018

Agreed

@lbalmaceda
Copy link
Contributor

@msalokangas @pragadeesh0106 I've proposed changes on #126. Feel free to try it and leave some feedback before we merge it.

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

Successfully merging a pull request may close this issue.

5 participants