Uncaught Error: Invalid argument(s): Auth0Client has not been initialized

Hello,

i’m currently facing an error regarding authentication with flutter web.

I am using the official package.

Sometimes the app build very long when also using the debugger. If using release mode it works directly.

If i build it and deploy it to an S3 Bucket (as a static website) i get this error when clicking the login button:

main.dart.js:5831  Uncaught Error: Invalid argument(s): Auth0Client has not been initialized
    at Object.c (main.dart.js:3364:19)
    at a9F.Hn (main.dart.js:45995:20)
    at a9F.MT (main.dart.js:45935:20)
    at main.dart.js:29408:14
    at aMB.a (main.dart.js:4730:63)
    at aMB.$2 (main.dart.js:40379:14)
    at Object.u (main.dart.js:4716:10)
    at Object.bfE (main.dart.js:29410:10)
    at Xl.aME (main.dart.js:29400:17)
    at Cg.VO (main.dart.js:104549:22)

I dont know how to provide any more detail to this, because it works in the local environment.

The way i use it is like this:

In my App (stateful widget) that is called by runApp() i have in my initstate this:

if (kIsWeb) {
      final auth0Web = ref.read(auth0WebInstanceProvider);

      auth0Web.onLoad().then(
        (final credentials) {
          if (credentials != null) {
            log("Logged in");
          } else {
            log("Logged out");
          }
        },
      ).onError(
        (error, stackTrace) {
          log(error.toString());
          log(stackTrace.toString());
        },
      );
    }

then im calling this on my on Pressed:

if (kIsWeb) {
    await ref.read(auth0WebInstanceProvider).loginWithRedirect(
          redirectUrl: dotenv.env['REDIRECT_URL']!,
        );
  }

and this is the auth0 provider:

final auth0WebInstanceProvider = Provider((ref) {
  return Auth0Web(
    dotenv.env['AUTH0_DOMAIN']!,
    dotenv.env['AUTH0_CLIENT']!,
  );
});

Does anyone have an idea or had a similar problem?

Hi @MeshApps!

I understand your Flutter application works locally, but as a static website deployed to an S3 bucket, you get an Uncaught Error: Invalid argument(s): Auth0Client has not been initialized error. Can you provide the tenant name, client_id, and the values of the env variables for both the working local version and the deployed version? You can send this information to me in a private message!

Best,

Mary Beth

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.