auth0 / auth0-flutter

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

No implementation found for method webAuth#login on channel auth0.com/auth0_flutter/web_auth #259

Closed ivantrave closed 1 year ago

ivantrave commented 1 year ago

Checklist

Description

I am currently using Flutter with the following versions:

Flutter 3.7.12 • channel stable • https://github.com/flutter/flutter.git Framework • revision 4d9e56e694 (4 weeks ago) • 2023-04-17 21:47:46 -0400 Engine • revision 1a65d409c7 Tools • Dart 2.19.6 • DevTools 2.20.1

And using the package auth0_flutter: ^1.1.0.

I followed the installation and configured both, iOS and Android to be able to login/logout users in my app.

For iOS it works like a charm but it does not work in Android (tested in emulators)

I am getting the following error after calling the login function:

Auth0 api = Auth0(<domain>, <myClientId>);

Future<Credentials> login() async {
  return await api.webAuthentication().login();
}
Exception: No implementation found for method webAuth#login on channel auth0.com/auth0_flutter/web_auth

I configured the auth0 allowed callback/logout URLs (notice I used https schema es suggested in the docs for Android) as following:

<myBundleId>://<domain>/ios/<myBundleId>/callback, https://<domain>/android/<myAppId>/callback

And updated the android/app/src/build.gradle file with the suggested configuration:

defaultConfig {
        applicationId "<myAppId>"
        ...
        minSdkVersion 21 // <--- min sdk version needed by auth0 package
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName

        manifestPlaceholders += [auth0Domain: "<domain>", auth0Scheme: "https"] // <--
    }

What am I missing here?

I would appreciate any help.

Many thanks.

PS: Official package documentation (https://pub.dev/packages/auth0_flutter) states that the manifestPlaceholders should be defined as following:

manifestPlaceholders = [auth0Domain: "company.us.auth0.com", auth0Scheme: "https"]

But that generates the following error:

Attribute application@name at AndroidManifest.xml:5:9-42 requires a placeholder substitution but no value for <applicationName> is provided.

since it is overwriting instead of just appending the auth0 properties. That is why I used the += instead

PS 2: Downgrading to version 1.0.2 works for both, Android and iOS

Reproduction

  1. Install specified versions (flutter and auth0_flutter packages)
  2. Run app in Android device (tested in emulator)
  3. Try to login

auth0_flutter version

1.1.0

Flutter version

3.7.12

Platform

Android

Platform version(s)

minSdk 21

Widcket commented 1 year ago

Hi @ivantrave, thanks for raising this. @poovamraj could you please take a look?

khomin commented 1 year ago

Oh Wish I had read this before trying Seems like $25/month for nothing is not enough to provide even a very primitive web example

stevehobbsdev commented 1 year ago

Thanks for raising @ivantrave - you confirmed in your issue that you were able to reproduce this in the Flutter sample app but it's working ok for me with no changes other than Auth0 tenant configuration (see video below running in an Android emulator). This sample uses webAuthentication().login() as you are doing (source).

https://github.com/auth0/auth0-flutter/assets/766403/a70b898b-4591-4550-b219-f504398ae45d

If you're able to provide a small reproducible sample that demonstrates the issue, I can take a look.

Thanks for the feedback on the manifest placeholders, I'll get that change made where appropriate.

Widcket commented 1 year ago

Closing due to inactivity. Please feel free to ping if you'd prefer to reopen.

auto-eric commented 1 year ago

I have the same problem. I checked out the example, put my clientID and the domain in the .env file. then flutter run -d linux. There is no configuration as for Android or iOS. Is there something I need to do?