@page "/counter"
@using System.Net.Http
@using System.Collections.Generic
@using System.Text.Json
@using System.Net.Http.Headers
@using Microsoft.AspNetCore.Components.Authorization
@using phronCare.UIBlazor.Services.Authorization
@inject HttpClient _httpClient
@inject AuthenticationStateProvider authenticationStateProvider
Current count: @currentCount
@code { private int currentCount = 0; private async void IncrementCount() { currentCount++; var customAuthStateProvider = (CustomAuthorizationProvider)authenticationStateProvider; var token = await customAuthStateProvider.GetTokenData(); if (!string.IsNullOrWhiteSpace(token.token)) { _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token.token); var response = _httpClient.GetAsync("/api/Test/administradores"); } } }