Пример #1
0
        // _perform_auth_request
        private async Task <Dictionary <string, string> > PerformAuthRequest(Dictionary <string, string> data)
        {
            HttpRequestMessage request = new HttpRequestMessage()
            {
                Method     = HttpMethod.Post,
                RequestUri = new Uri("https://android.clients.google.com/auth", UriKind.Absolute)
            };
            var keyValues = new List <KeyValuePair <string, string> >();

            foreach (var kvp in data)
            {
                keyValues.Add(new KeyValuePair <string, string>(kvp.Key, kvp.Value));
            }

            request.Headers.Add("User-Agent", userAgent);
            string result = "";

            try
            {
                request.Content = new HttpFormUrlEncodedContent(keyValues);
                HttpResponseMessage response = await client.SendRequestAsync(request);

                if (response.IsSuccessStatusCode == false)
                {
                    throw new Exception();
                }
                result = await response.Content.ReadAsStringAsync();
            }
            catch (Exception e)
            {
                throw e;
            }
            return(GoogleKeyUtils.ParseAuthResponse(result));
        }
Пример #2
0
 public GPSOAuthClient(string email, string password)
 {
     this.email    = email;
     this.password = password;
     client        = new HttpClient();
     androidKey    = GoogleKeyUtils.KeyFromB64(b64Key);
 }
Пример #3
0
        // perform_master_login
        public async Task <Dictionary <string, string> > PerformMasterLogin(string android_id, string service = "ac2dm",
                                                                            string deviceCountry = "us", string operatorCountry = "us", string lang = "en", int sdkVersion = 21)
        {
            string signature = GoogleKeyUtils.CreateSignature(email, password, androidKey);
            //string signature = @"AFcb4KS_5Yp0W66fYbt1IjFCaYVTNW6cRAKk8VzOh9RGFef8Jsv3aUvW7bNxap3aNVbVbCQ3p4k4Hp17bxxjzd3ekoiD34POjpJG0RGHx8a8aaRo5xYT2k3Aw5oReZvvLck_VnEjuDTPzSS4iolk3iASYedgc20uXB2dZTts_fM0hgWZHg==";
            var dict = new Dictionary <string, string> {
                { "accountType", "HOSTED_OR_GOOGLE" },
                { "Email", email },
                { "has_permission", 1.ToString() },
                { "add_account", 1.ToString() },
                { "EncryptedPasswd", signature },
                { "service", service },
                { "source", "android" },
                { "device_country", deviceCountry },
                { "operatorCountry", operatorCountry },
                { "lang", lang },
                // { "androidId", android_id },
                { "sdk_version", sdkVersion.ToString() }
            };

            return(await PerformAuthRequest(dict));
        }