auth0 / auth0-flutter

Auth0 SDK for Flutter
https://pub.dev/documentation/auth0_flutter/latest/
Apache License 2.0
59 stars 39 forks source link

Login using webAuthentication is not working on Android. #284

Closed HasanAlqaisi closed 1 year ago

HasanAlqaisi commented 1 year ago

Checklist

Description

I am trying to Implement login with google & apple. Everything is working great on IOS but not for Android.

This is what happens when trying to login with Google: Only the First time It shows the list of my google accounts. When I click on one of them, the blank page is shown. And no matter how much I try again the blank page will appear

https://github.com/auth0/auth0-flutter/assets/57685540/8167f553-0618-4b1b-b222-06ae684d5919

And if I try login with Apple, the page will stuck like this:

https://github.com/auth0/auth0-flutter/assets/57685540/648bfa4e-6f5a-4a89-b17c-6941c42725d4

Reproduction

  1. Click on a button that calls this function:
    await auth0.webAuthentication(scheme: "demo").login(
        parameters: {'connection': "apple"},
      )

    And the rest is as described above.

Additional context

logs:

D/TWAProviderPicker( 5722): Found TWA provider, finishing search: com.android.chrome
V/CustomTabsController( 5722): Trying to bind the service
V/CustomTabsController( 5722): Bind request result (com.android.chrome): true
V/CustomTabsController( 5722): Trying to bind the service
V/CustomTabsController( 5722): Bind request result (com.android.chrome): true
D/CustomTabsController( 5722): CustomTabs Service connected
D/CustomTabsController( 5722): Launching URI. Custom Tabs available: true
E/OpenGLRenderer( 5722): Unable to match the desired swap behavior.
W/Parcel  ( 5722): Expecting binder but got null!

Here's my setup for android:

strings.xml:

    <string name="com_auth0_domain">{http://***.com}</string>
    <string name="com_auth0_scheme">demo</string>

build.gradle: manifestPlaceholders += [auth0Domain: "@string/com_auth0_domain", auth0Scheme: "@string/com_auth0_scheme"]

In code:

  Auth0 auth0 = Auth0(
    'https://***.com', // domain
    '**********************', // clientID
  );

On button click:

await auth0.webAuthentication(scheme: "demo").login(
        parameters: {'connection': "apple"},
      )

auth0_flutter version

1.2.1

Flutter version

Channel stable, 3.10.5

Platform

Android

Platform version(s)

Android 13

Widcket commented 1 year ago

Hi @HasanAlqaisi, thanks for raising this.

@poovamraj could you please take a look?

HasanAlqaisi commented 1 year ago

I think this is happening because the application type in auth0 settings is SPA rather than native. But why SPA is working fine with an IOS simulator?

miguel-krasamo commented 1 year ago

I think this is happening because the application type in auth0 settings is SPA rather than native. But why SPA is working fine with an IOS simulator?

We are facing the same issue but we have the app settings configured to native

HasanAlqaisi commented 1 year ago

I think this is happening because the application type in auth0 settings is SPA rather than native. But why SPA is working fine with an IOS simulator?

We are facing the same issue but we have the app settings configured to native

I've made another application configured to native and it's working fine.

HasanAlqaisi commented 1 year ago

I managed to fix this. For me it wasn't about the application type, but the app domain.

First issue is that I added https to the domain by mistake. And the second one is in strings.xml instead of: <string name="com_auth0_domain">@string/auth0_domain</string> I did: <string name="com_auth0_domain">{@string/auth0_domain}</string>