Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }