/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { VerifySoftwareTokenResponse response = new VerifySoftwareTokenResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Session", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Session = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Status", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Status = unmarshaller.Unmarshall(context); continue; } } return(response); }
/// <summary> /// Use for confirm software mfa token via authentication. /// </summary> /// <param name="code">Software mfa token from app</param> /// <param name="sessionToken">Not required, may be null. Use in <see cref="VerifySoftwareTokenRequest"/></param> /// <returns></returns> public async Task <bool> VerifySoftwareTokenAsync(string code, string sessionToken = null) { if (string.IsNullOrEmpty(code)) { throw new ArgumentNullException(nameof(code)); } EnsureUserAuthenticated(); VerifySoftwareTokenRequest request = new VerifySoftwareTokenRequest { AccessToken = SessionTokens.AccessToken, FriendlyDeviceName = Device.GetDeviceName() ?? string.Empty, Session = sessionToken, UserCode = code }; VerifySoftwareTokenResponse response = await Provider.VerifySoftwareTokenAsync(request).ConfigureAwait(false); return(response.Status == VerifySoftwareTokenResponseType.SUCCESS); }