Skip to content

Calling onLoad() throws missing_transaction - Invalid state even when hasValidCredentials() returns true #554

Open
@AcarFurkan

Description

@AcarFurkan

Checklist

Description

When calling auth0Web.onLoad(...), a WebException is thrown with the error code missing_transaction and message Invalid state. However, right after this exception, calling auth0Web.hasValidCredentials() returns true.

This seems inconsistent — if the state is invalid and an error is thrown during onLoad, shouldn't hasValidCredentials() also return false?

Reproduction


@override
Future<bool> initAuthSession() async {
  try {
    await auth0Web.onLoad(
      useRefreshTokens: true,
      cacheLocation: CacheLocation.localStorage,
      scopes: {'openid', 'profile', 'offline_access', 'email'},
      audience: BuildConfig.auth0_audience,
    );
    return await auth0Web.hasValidCredentials();
  } on WebException catch (e) {
    final hasValidCredentials = await auth0Web.hasValidCredentials();
    debugPrint('WebException hasValidCredentials: $hasValidCredentials ');
    debugPrint('WebException error: ${e.code} - ${e.message} - ${e.details} ');
    return false;
  } catch (e) {
    final hasValidCredentials = await auth0Web.hasValidCredentials();
    debugPrint('init Unknown hasValidCredentials: $hasValidCredentials - $e');
    return false;
  }
}

Additional context

No response

auth0_flutter version

1.9.0

Flutter version

3.29.2

Platform

Web

Platform version(s)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug reportThis issue reports a suspect bug or issue with the SDK itselfweb

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions