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
51 stars 50 forks source link

Clearing cache to sign in with other user. #114

Closed cnschnei-btc closed 2 months ago

cnschnei-btc commented 2 months ago

Is your feature request related to a problem? Please describe.

If I logout and then want to login again it redirects into the webview, then redirects directly back into the app without requesting new credentials.

Describe the solution you'd like

I would like to have a parameter or a function that I can use to delete that cached credentials if you want to switch the account you are using.

ThexXTURBOXx commented 2 months ago

I think it is not as easily possible as people might think it is: Logging out can be a process which differs from app to app. Some apps like to use persistent cookies, which are not only there for storing login information, but also other stuff. Just clearing the cookies introduces unwanted additional behaviour in these cases. Hence, when I was asked about adding logout functionality some time ago (here: https://github.com/ThexXTURBOXx/flutter_web_auth_2/issues/49#issuecomment-1694753277), I suggested to use another dedicated call to authenticate, which calls the logout endpoint and redirects to the app just like the login does. Sadly, this is really the best way this can be accomplished. If you want to clear the cookies to log the user out, nothing is stopping you, though. flutter_web_auth_2 uses built-in mechanisms to accomplish the login process: On Android, is uses Chrome Custom Tabs via AndriodX browser; on Apple devices it uses the ASWebAuthenticationSession or SFAuthenticationSession (depending on the current OS version); in the browser it just uses standard tabs; and on Windows and Linux it uses desktop_webview_window or a HttpServer running in the background, listening for feedback (depending on which approach you configured). You can write dedicated code which clears the corresponding cookies/state in each of these approaches.

Hence, I will close this as "not planned" for the time being! I hope that helped clearing things up!