public async Task <IActionResult> SignIn(User user) { if (!ModelState.IsValid) { return(ResponseMessageHelper.ModelStateInvalid(ModelState)); } var cognito = new AmazonCognitoIdentityProviderClient(_region); var request = new AdminInitiateAuthRequest { UserPoolId = _config.Value.AwsCognitoUserPoolId, ClientId = _config.Value.AwsCognitoAppClientId, AuthFlow = AuthFlowType.ADMIN_NO_SRP_AUTH }; request.AuthParameters.Add("USERNAME", user.Username); request.AuthParameters.Add("PASSWORD", user.Password); try { var response = await cognito.AdminInitiateAuthAsync(request); return(ResponseMessageHelper.Ok(response.AuthenticationResult.IdToken)); } catch (NotAuthorizedException ex) { return(ResponseMessageHelper.Unauthorized(ex.Message)); } catch (Exception ex) { return(ResponseMessageHelper.InternalServerError(ex.Message)); } }