| 12345678910111213141516171819202122232425262728293031323334353637 |
- @page "/callback"
- @using NemAnBlazor.Services.Interfaces
- @inject NavigationManager NavigationMgr
- @inject IAuthClientService AuthService
- @inject Blazored.SessionStorage.ISessionStorageService sessionStorage
- <PageTitle>Callback page</PageTitle>
-
-
- <p role="status">Current count: @currentCount</p>
-
- <button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
-
- @code {
- private int currentCount = 0;
-
- private void IncrementCount()
- {
- currentCount++;
- }
- protected override async Task OnInitializedAsync()
- {
- string url = NavigationMgr.Uri;
-
- //code is the only parameter in the url
- string code = url.Split("=")[1];
-
- var response = await AuthService.GetAccessToken(new GrpcShared.DTO.Auth.TokenRequest { code = code});
-
-
- //store access token in local storage
- await sessionStorage.SetItemAsync("token", response.access_token);
- await sessionStorage.SetItemAsync("refresh_token", response.refresh_token);
-
- //redirect to home
- NavigationMgr.NavigateTo("/home");
- }
- }
|