public async Task <bool> LoginAsync(LoginParamsType model) { var document = await _httpClient.GetDiscoveryDocumentAsync(); var tokenResult = await _httpClient.RequestPasswordTokenAsync(new PasswordTokenRequest { Address = document.TokenEndpoint, UserName = model.UserName, Password = model.Password, ClientId = _options.ProviderOptions.ClientId, Scope = string.Join(" ", _options.ProviderOptions.DefaultScopes) }); if (!tokenResult.IsError) { await _accessTokenService.SaveAccessToken(tokenResult); ((ApiAuthenticationStateProvider)_authenticationStateProvider).MarkUserAsAuthenticated(model.UserName); _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", tokenResult.AccessToken); return(true); } return(false); }
public Task LoginAsync(LoginParamsType model) { // todo: login logic return(Task.CompletedTask); }
public async Task <bool> LoginAsync(LoginParamsType model) { return(await _client.LoginAsync(model.UserName, model.Password)); }