src/AWSSDK.Extensions.CognitoAuthentication/CognitoUserAuthentication.cs
/// <summary>
/// Uses the properties of the RespondToSmsMfaRequest object to respond to the current MFA 
/// authentication challenge using an asynchronous call
/// </summary>
/// <param name="smsMfaRequest">RespondToSmsMfaRequest 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>
Uses the properties of the RespondToSmsMfaRequest object to respond to the current MFA
authentication challenge using an asynchronous call
Uses the properties of the RespondToSmsMfaRequest object to respond to the current MFA authentication challenge using an asynchronous call
public void RespondToSmsMfaAuthAsync(RespondToSmsMfaRequest smsMfaRequest, AsyncCallback<AuthFlowResponse> callback = null)
        {
            RespondToAuthChallengeRequest challengeRequest = new RespondToAuthChallengeRequest
            {
                ChallengeResponses = new Dictionary<string, string>
                    {
                        { CognitoConstants.ChlgParamSmsMfaCode, smsMfaRequest.MfaCode},
                        { CognitoConstants.ChlgParamUsername, Username }
                    },
                Session = smsMfaRequest.SessionID,
                ClientId = ClientID,
                ChallengeName = ChallengeNameType.SMS_MFA
            };
            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));
            });
        }
public void RespondToSmsMfaAuthAsync ( RespondToSmsMfaRequest smsMfaRequest , AsyncCallback < AuthFlowResponse > callback = null ) { RespondToAuthChallengeRequest challengeRequest = new RespondToAuthChallengeRequest { ChallengeResponses = new Dictionary < string , string > { { CognitoConstants . ChlgParamSmsMfaCode , smsMfaRequest . MfaCode } , { CognitoConstants . ChlgParamUsername , Username } } , Session = smsMfaRequest . SessionID , ClientId = ClientID , ChallengeName = ChallengeNameType . SMS_MFA } ; 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 ) ) ; } ) ; }
Uses the properties of the RespondToSmsMfaRequest object to respond to the current MFA
authentication challenge using an asynchronous call
Uses the properties of the RespondToSmsMfaRequest object to respond to the current MFA authentication challenge using an asynchronous call
Returns the AuthFlowResponse object that can be used to respond to the next challenge,
if one exists
Returns the AuthFlowResponse object that can be used to respond to the next challenge if one exists
smsMfaRequest
RespondToSmsMfaRequest
RespondToSmsMfaRequest object containing the necessary parameters to
respond to the current SMS MFA authentication challenge
RespondToSmsMfaRequest object containing the necessary parameters to respond to the current SMS MFA authentication challenge
callback
AsyncCallback<AuthFlowResponse>