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

How to get token in Blazor WASM (.NET 8)

$
0
0

I use Blazor WASM application (.NET 8) with Keycloak OpenId. The problem is I have no idea how to access the token from code (I want to store it to use later for logout as token_id_hint).

There are no handlers I can add my method to AddOidcAuthentication configuration:

builder.Services.AddOidcAuthentication(options =>{    options.ProviderOptions.MetadataUrl = "https://my-domain.com/.well-known/openid-configuration";    options.ProviderOptions.Authority = "https://my-domain.com/realms/my-realm";    options.ProviderOptions.ClientId = "website-auth";    options.ProviderOptions.ResponseType = "id_token token";    options.UserOptions.NameClaim = "preferred_username";    options.UserOptions.RoleClaim = ClaimTypes.Role;    options.UserOptions.ScopeClaim = "scope";}).AddAccountClaimsPrincipalFactory<CustomAccountClaimsPrincipalFactory>();

Also I can't intercept it using IAccessTokenProviderAccessor, it always returns empty token:

var tokenResult = await AccessTokenProvier.RequestAccessToken();

How do I get my token in .NET 8 + OIDC?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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