Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to add google authentication to an existing Blazor WASM app with ASP.NET Core 8 Web API

$
0
0

I'm developing a Blazor WASM standalone front-end, connected to a ASP.NET Core 8 Web API I'm also working on. Everything is in .NET 8.

Currently, my authentication flow is pretty simple:

  1. User enters his credentials in the login page
  2. A call is done to my Web API "login" endpoint
  3. The Web API returns a token and refresh token
  4. Wasm save this in localStorage and the user is now authenticated.
  5. Before each httpRequest to API, an interceptor checks if the token is still valid according to the expiration time. If it's not, then wasm calls the Web API "refreshToken" endpoint.

Current Auth flow

This is currently working pretty nice.

First of all, I'm wondering if I'm actually doing it the right way.. Is it secured enough ? Wouldn't it be better to use OpenIddict in the Web API instead of doing all of this manually?

But the main question is the following one : I would like to add Google SSO to my Blazor Wasm according to the microsoft documentation and here's my plan.

  1. User clicks on "Sign in with google", and logs himself in
  2. Wasm receives a callback with an IdToken
  3. Wasm sends this IdToken to my Web API
  4. Web API verifies this is an actual valid google token, and creates the user if not exist.
  5. Web API returns a token and refreshToken as if the user had logged on in classic mode.

Is it the right way to do it ? What do you think about this ?

Thanks in advance for your help


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>