/// <summary> /// Uses the properties of the RespondToNewPasswordRequiredRequest object to respond to the current new /// password required authentication challenge using an asynchronous call /// </summary> /// <param name="newPasswordRequest">RespondToNewPasswordRequiredRequest object containing the necessary /// parameters to respond to the current SMS MFA authentication challenge</param> /// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge, /// if one exists</returns> public async Task <AuthFlowResponse> RespondToNewPasswordRequiredAsync(RespondToNewPasswordRequiredRequest newPasswordRequest) { RespondToAuthChallengeRequest challengeRequest = new RespondToAuthChallengeRequest { ChallengeResponses = new Dictionary <string, string> { { CognitoConstants.ChlgParamNewPassword, newPasswordRequest.NewPassword }, { CognitoConstants.ChlgParamUsername, Username } }, Session = newPasswordRequest.SessionID, ClientId = ClientID, ChallengeName = ChallengeNameType.NEW_PASSWORD_REQUIRED }; if (!string.IsNullOrEmpty(SecretHash)) { challengeRequest.ChallengeResponses.Add(CognitoConstants.ChlgParamSecretHash, SecretHash); } RespondToAuthChallengeResponse challengeResponse = await Provider.RespondToAuthChallengeAsync(challengeRequest).ConfigureAwait(false); UpdateSessionIfAuthenticationComplete(challengeResponse.ChallengeName, challengeResponse.AuthenticationResult); return(new AuthFlowResponse(challengeResponse.Session, challengeResponse.AuthenticationResult, challengeResponse.ChallengeName, challengeResponse.ChallengeParameters, new Dictionary <string, string>(challengeResponse.ResponseMetadata.Metadata))); }
/// <summary> /// Uses the properties of the RespondToNewPasswordRequiredRequest object to respond to the current new /// password required authentication challenge using an asynchronous call /// </summary> /// <param name="newPasswordRequest">RespondToNewPasswordRequiredRequest object containing the necessary /// parameters to respond to the current SMS MFA authentication challenge</param> /// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge, /// if one exists</returns> public void RespondToNewPasswordRequiredAsync(RespondToNewPasswordRequiredRequest newPasswordRequest, AsyncCallback <AuthFlowResponse> callback = null) { RespondToAuthChallengeRequest challengeRequest = new RespondToAuthChallengeRequest { ChallengeResponses = new Dictionary <string, string> { { CognitoConstants.ChlgParamNewPassword, newPasswordRequest.NewPassword }, { CognitoConstants.ChlgParamUsername, Username } }, Session = newPasswordRequest.SessionID, ClientId = ClientID, ChallengeName = ChallengeNameType.NEW_PASSWORD_REQUIRED }; if (!string.IsNullOrEmpty(SecretHash)) { challengeRequest.ChallengeResponses.Add(CognitoConstants.ChlgParamSecretHash, SecretHash); } Provider.RespondToAuthChallengeAsync(challengeRequest, r => { if (r.Exception != null) { callback?.Invoke(new AsyncResult <AuthFlowResponse>(null, r.Exception)); return; } RespondToAuthChallengeResponse challengeResponse = r.Response; UpdateSessionIfAuthenticationComplete(challengeResponse.ChallengeName, challengeResponse.AuthenticationResult); callback?.Invoke(new AsyncResult <AuthFlowResponse>(new AuthFlowResponse() { SessionID = challengeResponse.Session, ChallengeName = challengeResponse.ChallengeName, AuthenticationResult = challengeResponse.AuthenticationResult, ChallengeParameters = challengeResponse.ChallengeParameters, ClientMetadata = new Dictionary <string, string>(challengeResponse.ResponseMetadata.Metadata) }, null)); }); }
/// <summary> /// Uses the properties of the RespondToNewPasswordRequiredRequest object to respond to the current new /// password required authentication challenge using an asynchronous call /// </summary> /// <param name="newPasswordRequest">RespondToNewPasswordRequiredRequest object containing the necessary /// parameters to respond to the current SMS MFA authentication challenge</param> /// <returns>Returns the AuthFlowResponse object that can be used to respond to the next challenge, /// if one exists</returns> public virtual Task <AuthFlowResponse> RespondToNewPasswordRequiredAsync(RespondToNewPasswordRequiredRequest newPasswordRequest) { return(RespondToNewPasswordRequiredAsync(newPasswordRequest, null)); }