Grid.Blazor
Grid.Blazor copied to clipboard
Authenticated grid loading problem
When I try to load from authenticated API errors occurred.
Page code:
protected override async Task OnParametersSetAsync()
{
string url = Navigation.BaseUri + Endpoint;
if (NeedAuthorization)
{
var tokenResult = await AuthenticationService.RequestAccessToken();
if (tokenResult.TryGetToken(out var token))
{
httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.Value}");
}
else
{
Navigation.NavigateTo(tokenResult.RedirectUrl);
}
}
var query = new QueryDictionary<StringValues>();
var client = new GridClient<T>(httpClient, url, query, false, Endpoint + "Grid",
Columns);
_grid = client.Grid;
_task = client.UpdateGrid();
await _task;
}
Browser shows errors. After a while, server API receives correct invocation and return rights data, but it's too late.
Browser log: https://pastebin.com/UM6g0fPt
Blazor WA returns very few error info and makes it difficult to debug.
You could try to move all authentication code to the OnInitialized method, but not sure if it will work fine consistentlly.
I think the best option is to run all authentication stuff in the App.razor component, and authorization in the NavMenu.razor component and the back-end web services.
You could try to move all authentication code to the OnInitialized method, but not sure if it will work fine consistentlly.
Same error.
I think the best option is to run all authentication stuff in the App.razor component, and authorization in the NavMenu.razor component and the back-end web services.
No, because I need to know server site who is calling API by JWT authorization token.