Klassic Mak
Klassic Mak

Reputation: 1

Loading Dialog Stuck after Login Attempt with Auth0 in Flutter Application

When users attempt to sign in using social authentication (e.g., Google, Facebook) through Auth0 in your Flutter app, the following issues are observed:

Stuck Loading Dialog: After the user successfully authenticates, the loading dialog remains visible and is not dismissed as expected.

No Debug Statements: There are no debug statements printed to indicate the progress or success of the login process after redirection.

Callback Handling: The app does not properly handle the callback from Auth0, resulting in the login success message not being displayed, and the user is not navigated to the intended screen.

Snippets:

  Future<Credentials> loginWithSocial(BuildContext context, String connection) async { try { _showLoadingDialog(context);

debugPrint('Starting social login process for connection: $connection');

  Credentials credentials =
      await auth0.webAuthentication(scheme: appScheme).login(
    useHTTPS: true,
    redirectUrl:
        'CALLBAC_KURL',
    audience: 'AUDIENCE',
    scopes: {'openid', 'profile', 'email'},
    parameters: {
      'connection': connection,
    },
  );
  if (kDebugMode) {
    print(" Testing mode :-" + credentials.accessToken);
  }

  debugPrint('Social login successful: ${credentials.idToken}');

  // Use the access token for authenticated requests
  makeAuthenticatedRequest(credentials.accessToken);

  return credentials;
} catch (e) {
  if (!kReleaseMode) {
    debugPrint(e.toString());
         debugPrint('Social login failed: $e');

  if (Navigator.canPop(context)) {
    Navigator.pop(context);
  }

  _showMessage(context, 'Social login failed: ${e.toString()}',
      success: false);
  }
  throw Exception();
  


}
}

The callback uri and the audinece are configured correctly, which worked with signing in with email and password

Upvotes: 0

Views: 26

Answers (0)

Related Questions