ThexXTURBOXx / flutter_web_auth_2

Flutter plugin for authenticating a user with a web service
https://pub.dev/packages/flutter_web_auth_2
MIT License
53 stars 54 forks source link

On Android, call to authenticate immediately returns CANCELED #8

Closed kylethompson002 closed 2 years ago

kylethompson002 commented 2 years ago

Describe the bug

When I make the call to FlutterWebAuth2.authenticate, the web view does not open, and it immediately returns PlatformException(CANCELED, User canceled login, null, null).

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

When FlutterWebAuth2.authenticate is called, a web view should open to the given url.

Screenshots

If applicable, add screenshots to help explain your problem.

Device (please complete the following information!)

Additional context

I can only reproduce this issue once our android app is built in release mode and distributed through the Play store. I cannot reproduce it when building locally with Android Studio in either debug or release mode. It also can not reproduce this issue in our iOS app (same flutter code).

ThexXTURBOXx commented 2 years ago

Thanks for reporting this issue. I have taken a look at your fork and noticed that you have removed the observer lines. Did that help by any chance? Depending on that, I will search for better solutions. I cannot reproduce the behavior in an app of mine, that's why. Also: Have you by chance tested the behavior on other (Android) devices also?

kylethompson002 commented 2 years ago

Thanks for your reply. I've been doing some more testing today. Removing the observer lines did not solve the issue. I have observed the issue on both of my Android devices (OnePlus 9 and Google Pixel XL). I'm a little puzzled as to why this only happens for me in release mode 🤔. I'm wondering if it could be an issue with CustomTabs.

ThexXTURBOXx commented 2 years ago

It also puzzles me that it does not work after removing those lines. That is really weird. I would not expect this to be an issue with Custom Tabs, however, you cannot be sure. You most likely use ProGuard for your final release. Maybe that causes some problem?

kylethompson002 commented 2 years ago

I finally found my issue. It was a stupid mistake on my part 🤦 . I had an intent filter for deep links that was intercepting the authenticate URL and not letting CustomTabs open. Thank you for the support.

ThexXTURBOXx commented 2 years ago

Okay, good to know for the future! Thank you very much for letting me know the solution! :)

kecson commented 5 months ago

I finally found my issue. It was a stupid mistake on my part 🤦 . I had an intent filter for deep links that was intercepting the authenticate URL and not letting CustomTabs open. Thank you for the support.

how to fix?

ThexXTURBOXx commented 5 months ago

how to fix?

Look through all your intent filters (and all the ones from the package you are depending on - they might also be the cause of the problem) and remove the ones which interfere with flutter_web_auth_2's intent filter

kecson commented 5 months ago

I finally found my issue. It was a stupid mistake on my part 🤦 . I had an intent filter for deep links that was intercepting the authenticate URL and not letting CustomTabs open. Thank you for the support.

your redirect_url is https scheme or custom url? can you show me the AndroidMainfest.xml and you redirect_url?

jaybconsulting commented 5 months ago

What if I want to set up both deep linking (so the user can click a link from somewhere else and it opens my app) and the callback URL? Based on this solution it feels like I can't do both because my deep link will just be intercepting my callback URL?