MaikuB / flutter_appauth

A Flutter wrapper for AppAuth iOS and Android SDKs
274 stars 246 forks source link

Problem with auth from a deep (app) link. #511

Closed GenixPL closed 2 months ago

GenixPL commented 3 months ago

We have encountered a problem with inability to login when an app is started from a deep (app) link.

I'm not sure how to provide a reproducing code, due to the keys, or logs, due to specificity of them, or if you expect any, but i for sure can show how it looks like: (the recording shows ability to log in from a separate app task, and inability to do it when activity is put into Slack's task; it's the same behavior for our production endpoints and/or non-debug build) https://github.com/user-attachments/assets/5c8e1558-4fbf-41d5-b4d5-7657904e053f

It seems to be related to android launch mode, a manifest workaround:

<activity
    android:name="net.openid.appauth.AuthorizationManagementActivity"
    android:launchMode="singleInstance"
    tools:replace="android:launchMode" />

makes the auth work, but we are left with empty app instances and the webview: https://github.com/user-attachments/assets/5f7805a9-d69f-40bd-88a0-941b64a92ad2

MaikuB commented 2 months ago

Not something I can directly help with as from what I know, it would either be to do with AppAuth Android SDK or you may also have to consider the launchMode for other activities e.g. the main activity of your app. Coincidentally team I work with had experienced a similar issue and solution was to use the snippet you shared

GenixPL commented 2 months ago

solution was to use the snippet you shared

and they weren't stuck with empty instances?

the appauth guy mentions that the problem is caused by the way the auth might be started (which is the case here)

Screenshot 2024-08-28 at 09 02 41
MaikuB commented 2 months ago

I'll ask to double check but that wasn't mentioned. As this is open-sourced, you could make the necessary modifications to see if it helps in your case. The code in the snippet of the post around the "not working example" is different than what the plugin does too

note: the link you provided isn't working properly

GenixPL commented 2 months ago

sry for the link, it was the same as in the first comment, https://github.com/openid/AppAuth-Android/issues/977#issuecomment-2129326556 this should point directly to the comment

i have started a fork, with intention of giving it as a solution, as this seems to be a general problem, but my memory of android led me to doing quite extensive changes and i wasnt certain about them

MaikuB commented 2 months ago

Confirmed there is an empty instance but tapping on it didn't do anything. Have you by chance tried changing the launchMode of other activities to see if that helped?

MaikuB commented 2 months ago

I've created a branch to experiment with this but you able to try using this branch and see if it solves the issue? https://github.com/MaikuB/flutter_appauth/tree/intent-handling

GenixPL commented 2 months ago

ive started playing with it again, and realized that everything has started working without any changes - no

<activity
    android:name="net.openid.appauth.AuthorizationManagementActivity"
    android:launchMode="singleInstance"
    tools:replace="android:launchMode" />

, so sth must have changed during the month and the issue isnt there anymore

MaikuB commented 2 months ago

Thanks for the update. I know you mentioned there was no changes but be keen to know what you find on what may solved it in case you find out

MaikuB commented 2 months ago

Out of interest, what is the launchMode for your app's main activity?

GenixPL commented 2 months ago

my bad, i forgot that im using a different computer - different emulator, this still doesnt work on the android 14 provided by samsung (which is a big share of the market), but seems to be working with a newer android 14, so probably not worth fixing

the main launch mode is android:launchMode="singleTop"

MaikuB commented 2 months ago

Thanks for the info. I've deleted the branch since the solution provided by others doesn't work either. Not sure there's more I can do in this case

GenixPL commented 2 months ago

nah, i dont think so, thanks