forked from FarmMaps/FarmMapsApiClient
AW-3569 Added posibility to login with username/password
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using FarmmapsApi.Models;
|
||||
using IdentityModel;
|
||||
using IdentityModel.Client;
|
||||
|
||||
namespace FarmmapsApi.Services
|
||||
@@ -40,6 +41,19 @@ namespace FarmmapsApi.Services
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<TokenResponse> GetTokenUsernamePasswordAsync(string tokenEndpointUrl, string grantClientId, string username, string password)
|
||||
{
|
||||
return await _httpClient.RequestPasswordTokenAsync(new PasswordTokenRequest()
|
||||
{
|
||||
Address = tokenEndpointUrl,
|
||||
UserName = username,
|
||||
Password = password,
|
||||
ClientId = grantClientId,
|
||||
GrantType = OidcConstants.GrantTypes.Password,
|
||||
Scope = string.Join(" ", _configuration.Scopes)
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<TokenResponse> RefreshTokensAsync(string tokenEndpointUrl, string refreshToken)
|
||||
{
|
||||
return await _httpClient.RequestRefreshTokenAsync(new RefreshTokenRequest()
|
||||
|
Reference in New Issue
Block a user