Пример #1
0
        /// <inheritdoc />
        public Task<AddUserResult> AuthenticateUserAsync(AccessToken accessToken, DeliveryType deliveryType, bool isUpdate = false, ApiType api = ApiType.Connect)
        {
            Condition.Requires(accessToken).IsNotNull();
            Condition.Requires(deliveryType).IsNotNull();

            AuthUserRequest authRequest = new AuthUserRequest(this.clientId, this.clientSecret, accessToken);
            authRequest.Options = new SendMethodRequest();
            authRequest.Options.SendMethod = new ExpandoObject();
            authRequest.Options.SendMethod.type = deliveryType.Value;

            return this.AuthUserInternal(authRequest, api, isUpdate);
        }
Пример #2
0
        /// <inheritdoc />
        public Task<AddUserResult> AuthenticateUserAsync(AccessToken accessToken, bool isUpdate = false, ApiType api = ApiType.Connect, params string[] mfaValues)
        {
            Condition.Requires(accessToken).IsNotNull();
            Condition.Requires(mfaValues).IsNotNull().IsNotEmpty();

            AuthUserRequest authRequest = new AuthUserRequest(this.clientId, this.clientSecret, accessToken);

            if (mfaValues.Length == 1) authRequest.MfaValue = mfaValues.FirstOrDefault();
            else authRequest.MfaValue = new List<string>(mfaValues);

            return this.AuthUserInternal(authRequest, api, isUpdate);
        }
Пример #3
0
        /// <summary>
        /// Internal helper for user auth.
        /// </summary>
        private async Task<AddUserResult> AuthUserInternal(AuthUserRequest request, ApiType api, bool isUpdate)
        {
            string endpoint = GetEndpoint(api, "step");

            HttpResponseMessage response = isUpdate
                                               ? await this.httpClient.PatchAsJsonAsync(endpoint, request)
                                               : await this.httpClient.PostAsJsonAsync(endpoint, request);

            return await this.ProcessAddOrAuthResponse(response);
        }
Пример #4
0
        /// <inheritdoc />
        public Task<AddUserResult> AuthenticateUserAsync(AccessToken accessToken, string deviceMask, bool isUpdate = false, ApiType api = ApiType.Connect)
        {
            Condition.Requires(accessToken).IsNotNull();
            Condition.Requires(deviceMask).IsNotNullOrWhiteSpace();

            AuthUserRequest authRequest = new AuthUserRequest(this.clientId, this.clientSecret, accessToken);
            authRequest.Options = new SendMethodRequest();
            authRequest.Options.SendMethod = new ExpandoObject();
            authRequest.Options.SendMethod.mask = deviceMask;

            return this.AuthUserInternal(authRequest, api, isUpdate);
        }