Example #1
0
        /// <summary>
        /// Sends a confirmation request to Cognito for a new CognitoDevice
        /// </summary>
        /// <param name="accessToken">The user pool access token for from the InitiateAuth or other challenge response</param>
        /// <param name="deviceKey">The device key for the associated CognitoDevice</param>
        /// <param name="deviceName">The friendly name to be associated with the corresponding CognitoDevice</param>
        /// <param name="passwordVerifier">The password verifier generated from GenerateDeviceVerifier for the corresponding CognitoDevice</param>
        /// <param name="salt">The salt generated from GenerateDeviceVerifier for the corresponding CognitoDevice</param>
        /// <returns></returns>
        public async Task <ConfirmDeviceResponse> ConfirmDeviceAsync(string accessToken, string deviceKey, string deviceName, string passwordVerifier, string salt)
        {
            var request = new ConfirmDeviceRequest
            {
                AccessToken = accessToken,
                DeviceKey   = deviceKey,
                DeviceName  = deviceName,
                DeviceSecretVerifierConfig = new DeviceSecretVerifierConfigType
                {
                    PasswordVerifier = passwordVerifier,
                    Salt             = salt
                }
            };

            return(await Provider.ConfirmDeviceAsync(request));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="deviceMetadata"></param>
        /// <param name="deviceFriendlyName"></param>
        /// <returns></returns>
        public async Task ConfirmDeviceAsync(NewDeviceMetadataType deviceMetadata, string deviceFriendlyName)
        {
            EnsureUserAuthenticated();
            if (deviceMetadata == null)
            {
                throw new ArgumentNullException(nameof(deviceMetadata));
            }

            string deviceKey      = deviceMetadata.DeviceKey;
            string deviceGroupKey = deviceMetadata.DeviceGroupKey;

            IDictionary <string, string> verificationParameters =
                CognitoDeviceHelper.GenerateVerificationParameters(deviceKey, deviceGroupKey);

            ConfirmDeviceRequest confirmDeviceRequest = new ConfirmDeviceRequest
            {
                AccessToken = SessionTokens.AccessToken,
                DeviceKey   = deviceKey,
                DeviceName  = deviceFriendlyName,
                DeviceSecretVerifierConfig = new DeviceSecretVerifierConfigType
                {
                    PasswordVerifier = verificationParameters["verifier"],
                    Salt             = verificationParameters["salt"]
                }
            };

            await Provider.ConfirmDeviceAsync(confirmDeviceRequest).ConfigureAwait(false);

            var type = new DeviceType
            {
                DeviceKey        = deviceKey,
                DeviceAttributes = new List <AttributeType>()
            };

            Device = new CognitoDevice(type, this)
            {
                GroupDeviceKey = deviceGroupKey,
                DeviceSecret   = verificationParameters["secret"]
            };
        }
 public void ConfirmDeviceAsync(ConfirmDeviceRequest request, AmazonServiceCallback <ConfirmDeviceRequest, ConfirmDeviceResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }