public async Task <AuthenticationResponseViewModel> AuthenticationAsync(AuthenticationRequestViewModel authenticationRequestViewModel) { var authenticationRequestModel = _mapper.Map <AuthenticationRequestModel>(authenticationRequestViewModel); var repoResult = await _applicationRepository.SelectAsync(authenticationRequestModel.TrackCode); if (repoResult == null) { _domainNotification.AddNotification("NotFound", "Application not found"); return(null); } var responseSso = await _ssoService.ConnectToken(new AuthenticationRequest() { ClientId = $"Like{repoResult.Id}", ClientSecret = repoResult.Secret, GrantType = "client_credentials", Scopes = new string[1] { "like-api" } }); if (responseSso is SsoError ssoError) { _domainNotification.AddNotification("SsoError", ssoError.ErrorMessage); return(null); } var connectTokenResponse = responseSso as AuthenticationResponse; return(_mapper.Map <AuthenticationResponseViewModel>(connectTokenResponse)); }
public async Task <ActionResult <AuthenticationResponseViewModel> > PostAsync(AuthenticationRequestViewModel authenticationRequestViewModel) { return(Ok(await _applicationService.AuthenticationAsync(authenticationRequestViewModel))); }