forked from FarmMaps/FarmMapsApiClient
AW-3569 Added posibility to login with username/password
This commit is contained in:
@@ -53,9 +53,16 @@ namespace FarmmapsApi.Services
|
||||
throw new AuthenticationException("Already seems to be authenticated");
|
||||
|
||||
var disco = await _openIdConnectService.GetDiscoveryDocumentAsync();
|
||||
var token = await _openIdConnectService.GetTokenClientCredentialsAsync(disco.TokenEndpoint,
|
||||
_configuration.ClientId, _configuration.ClientSecret);
|
||||
|
||||
var usePasswordGrant = string.IsNullOrEmpty(_configuration.ClientId) ||
|
||||
string.IsNullOrEmpty(_configuration.ClientSecret);
|
||||
|
||||
var token = usePasswordGrant ?
|
||||
await _openIdConnectService.GetTokenUsernamePasswordAsync(disco.TokenEndpoint,
|
||||
_configuration.GrantClientId, _configuration.Username, _configuration.Password) :
|
||||
await _openIdConnectService.GetTokenClientCredentialsAsync(disco.TokenEndpoint,
|
||||
_configuration.ClientId, _configuration.ClientSecret);
|
||||
|
||||
if (token.IsError)
|
||||
throw new AuthenticationException(token.Error);
|
||||
|
||||
@@ -314,7 +321,6 @@ namespace FarmmapsApi.Services
|
||||
farmmapsUploader.UploadSessionData += data => location = data.UploadUri;
|
||||
|
||||
var progress = await farmmapsUploader.UploadAsync();
|
||||
|
||||
return new UploadResults(progress, location);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user