OAuth2 with Flutter Web

Robin Janke
Mar 8, 2021

--

Sometimes it can be very difficult to handle OAuth with Flutter (Web).

I have done it the following way but can’t find any official documentation about this:

Add the route to the main MaterialApp:

main.dart file handling the #/callback Route

Next create the AuthService:

Next create a filled called callback.html in your web folder:

Now you got OAuth2 working on Flutter Web and Flutter Mobile. If you wanna got an Authorization Header value to call your backend you can use this._authService.getAccessTokenIfLoggedIn.

--

--

Robin Janke
Robin Janke

Written by Robin Janke

Freelance DevOps Engineer & App Developer. Find me at www.robin-janke.de

Responses (1)