Oauth2 flow in Flutter app

Viewed 8370

In the Flutter app I'm currently building, I need to authenticate users against a custom (so non-Google/Facebook/Twitter/etc) authorization server.

In order to achieve this, the users should fill in their credentials in a webpage. To this purpose, the WebView-plugin can be used. However, when the page is redirected after the user authenticated, the WebView should be closed, and the code passed on to the (Flutter) function that initially called the WebView.

Having done some research already, I came accross the following options:

  • This blog post uses a local server, which still requires the user to manually close the window, which is not a real solution (in my opinion).
  • This issue marks integration with any OAuth provider as done, but does not provide any details on the user authentication inside the browser.
  • This issue is exactly like I am describing, but at the bottom it is mentioned that the WebView plugin provides a way to close the WebView. While it does indeed have a close()-function, I cannot find a way to trigger it on the redirect-URI and return the verification code.

Does a solution exist, that closes the browser automatically once the redirect-URI is opened (and also returns the verification code)?

Thanks in advance!

2 Answers
Related