Exemple #1
0
        /// <summary>
        /// Verify the auth code, call this method second
        /// </summary>
        /// <param name="expectation">"Data" member from the object that is returned after invoking GetAuthCodeAsync</param>
        /// <param name="auth_code">The received auth code</param>
        /// <param name="auth_type">Type of auth</param>
        /// <param name="locale">Locale</param>
        /// <returns></returns>
        private async Task <TinderResponse <ValidationData> > VerifyCodeAsync(OtpExpectation expectation, int auth_code, string auth_type = "sms", string locale = "en-GB")
        {
            if (auth_type != "sms")
            {
                this.TinderClientErrored?.Invoke("Only SMS auth is supported");
                return(null);
            }
            if (expectation.Length != auth_code.ToString().Length)
            {
                this.TinderClientErrored?.Invoke("Auth Code is not the expected Length");
                return(null);
            }
            var res = await Http.PostAsync(new Uri($"{Http.BaseAddress}/v2/auth/sms/validate?auth_type={auth_type}&locale={locale}"), new StringContent(JsonConvert.SerializeObject(new ValidatePayload()
            {
                IsUpdate = false,
                OtpCode = auth_code.ToString(),
                PhoneNumber = this.CurrentUser.PhoneNumber.ToString()
            }), Encoding.UTF8, "application/json")).ConfigureAwait(false);

            var cont = await res.Content.ReadAsStringAsync().ConfigureAwait(false);

            var data = JsonConvert.DeserializeObject <TinderResponse <ValidationData> >(cont);

            if (!data.Data.Validated)
            {
                TinderClientErrored?.Invoke("Validation has Failed");
            }
            this.CurrentUser.RefreshToken = data.Data.RefreshToken;
            return(data);
        }
Exemple #2
0
        /// <summary>
        /// Get auth code from Tinder, call this method first
        /// </summary>
        /// <param name="phone_number">Your Phone Number</param>
        /// <param name="area_code">Phone Area Code</param>
        /// <param name="auth_type">Type of auth</param>
        /// <param name="locale">Locale</param>
        /// <returns></returns>
        private async Task <TinderResponse <OtpExpectation> > GetAuthCodeAsync(ulong phone_number, int area_code, string auth_type = "sms", string locale = "en-GB")
        {
            if (auth_type != "sms")
            {
                this.TinderClientErrored?.Invoke("Only SMS auth is supported");
                return(null);
            }
            var numstr = (phone_number.ToString().StartsWith(area_code.ToString())) ? phone_number.ToString() : $"{area_code}{phone_number}";

            this.CurrentUser.PhoneNumber = phone_number;
            this.CurrentUser.AreaCode    = area_code;
            var res = await Http.PostAsync($"{Http.BaseAddress}/v2/auth/sms/send?auth_type={auth_type}&locale={locale}", new StringContent(string.Concat(@"{""phone_number"":""", numstr, @"""}"), Encoding.UTF8, "application/json")).ConfigureAwait(false);

            var cont = await res.Content.ReadAsStringAsync().ConfigureAwait(false);

            var data = JsonConvert.DeserializeObject <TinderResponse <OtpExpectation> >(cont);

            if (!data.Data.HasSmsSent)
            {
                TinderClientErrored?.Invoke("Otp Token has not been sent");
            }
            return(data);
        }