Android error: a0.authentication_canceled: The user closed the browser app and the authentication was canceled.
Checklist
- [X] The issue can be reproduced in the auth0_flutter sample app (or N/A).
- [X] I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- [X] I have looked into the API documentation and have not found a suitable solution or answer.
- [X] I have searched the issues and have not found a suitable solution or answer.
- [X] I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- [X] I agree to the terms within the Auth0 Code of Conduct.
Description
I clone this repo to play with the example app and follow the steps to use my domain and client id. I renamed .env.example to .env and filled with my values. Same for strings.xml.example to strings.xml and replace with my values. I edited the example app L54 and L83, with these code:
// L54
final result = await auth0.webAuthentication().login(
redirectUrl: '<my_package_id>://login-callback',
useEphemeralSession: true,
);
// L83
await auth0.webAuthentication().logout(
returnTo: '<my_package_id>://logout-callback');
and run the app in both iOS and Android. It works on iOS, after tapping on Web Auth Login button, I can see the web page, enter my email and password and tap Log In, then I can see the idToken printed in the Flutter app. But when I run the same code on Android (both simulator or actual device) I always see the web page being dismissed automatically without user interaction and this is the error :
a0.authentication_canceled: The user closed the browser app and the authentication was canceled.
How can I fix that code? What am I missing to configure in Android to make it work?
Reproduction
- clone repo
- edit
envfile with your values - edit
strings.xmlwith your values - edit
webAuthLogin()method L54 with:
final result = await auth0.webAuthentication().login(
redirectUrl: '<my_package_id>://login-callback',
useEphemeralSession: true,
);
- edit
webAuthLogout()method L83 with:
await auth0.webAuthentication().logout(
returnTo: '<my_package_id>://logout-callback');
- run the app on iOS, tap on 'Web Auth Login', you will be able to log in and the
idTokenwill be printed in the Flutter app. - run the app on Android, tap on 'Web Auth Login',, you will see the web being launched and dismissed automatically without user interaction. And error is
a0.authentication_canceled: The user closed the browser app and the authentication was canceled.
Additional context
No response
auth0_flutter version
auth0_flutter
Flutter version
3.19.3
Platform
Android, iOS
Platform version(s)
No response
This is a video of what I am seeing:
https://github.com/auth0/auth0-flutter/assets/7014968/a8894943-e0d2-4893-b987-49bc8c0b1aa6
@fbernaly Did you find a fix for this issue? I am facing same issue in Android.
We had this exact issue. If you're using https in Auth0, you need to add the SHA256 fingerprints of your app’s signing certificate. You can update it here: Applications > Specific Application > Settings > Advanced Settings > Device Settings > Key Hashes
We are facing the same error. @rileyjhardy Do you have a solution if the app is not signed yet during the development phase?
Edit: We are now using a custom scheme.
any fix here? same issue in Android samsung - SM-G998U1
Hi all, if this is happening for you with a custom scheme –are you using an emulator or a real device? Some emulators may not have a browser installed that supports Custom Tabs.
In you're using HTTPS, then you need to set up App Links, and that includes adding your app's SHA256 fingerprints to your Auth0 application's configuration. This is analogous as to how using HTTPS callbacks with iOS requires setting up an Associated Domain.
Closing, as I believe the above answers your questions. Feel free to chime back in if you'd prefer to reopen.