Ejemplo n.º 1
0
#pragma warning disable 1998
        public async Task <string> GetAccessToken()
#pragma warning restore 1998
        {
            var client   = new GPSOAuthClient(email, password);
            var response = client.PerformMasterLogin();

            if (response.ContainsKey("Error"))
            {
                throw new GoogleException(response["Error"]);
            }

            //Todo: captcha/2fa implementation

            if (!response.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            var oauthResponse = client.PerformOAuth(response["Token"],
                                                    "audience:server:client_id:848232511240-7so421jotr2609rmqakceuu1luuq0ptb.apps.googleusercontent.com",
                                                    "com.nianticlabs.pokemongo",
                                                    "321187995bc7cdc2b5fc91b11a96e2baa8602c62");

            if (!oauthResponse.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            return(oauthResponse["Auth"]);
        }
        public static string DoLogin(string username, string password)
        {
            GPSOAuthClient client = new GPSOAuthClient(username, password);
            Dictionary <string, string> response = client.PerformMasterLogin();

            if (response.ContainsKey("Error"))
            {
                throw new GoogleException(response["Error"]);
            }

            //Todo: captcha/2fa implementation

            if (!response.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            Dictionary <string, string> oauthResponse = client.PerformOAuth(response["Token"],
                                                                            "audience:server:client_id:848232511240-7so421jotr2609rmqakceuu1luuq0ptb.apps.googleusercontent.com",
                                                                            "com.nianticlabs.pokemongo",
                                                                            "321187995bc7cdc2b5fc91b11a96e2baa8602c62");

            if (!oauthResponse.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            return(oauthResponse["Auth"]);
        }
Ejemplo n.º 3
0
#pragma warning disable 1998
        public async Task <string> GetAccessToken()
#pragma warning restore 1998
        {
            var client   = new GPSOAuthClient(email, password);
            var response = await client.PerformMasterLogin(androidId : GoogleLoginAndroidId);

            if (response.ContainsKey("Error"))
            {
                if (response.ContainsKey("Url"))
                {
                    await Launcher.LaunchUriAsync(new Uri(response["Url"]));
                }
                else
                {
                    throw new GoogleException(response["Error"]);
                }
            }

            //Todo: captcha/2fa implementation

            if (!response.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            var oauthResponse = await client.PerformOAuth(response["Token"], GoogleLoginService, GoogleLoginAndroidId, GoogleLoginApp, GoogleLoginClientSig);

            if (!oauthResponse.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            return(oauthResponse["Auth"]);
        }
Ejemplo n.º 4
0
#pragma warning disable 1998
        public async Task <string> GetAccessToken()
#pragma warning restore 1998
        {
            var client = new GPSOAuthClient(email, password);
            Dictionary <string, string> response = null;

            try
            {
                response = client.PerformMasterLogin();
            } catch (NullReferenceException)
            {
                throw new InvalidResponseException();
            };

            if (response.ContainsValue("NeedsBrowser"))
            {
                Logger.Error("Your Google Account uses 2FA. Create a Password for the Application here:");
                Logger.Error("https://security.google.com/settings/security/apppasswords");
                Logger.Error("And use that for Login with Google.");
                Logger.Error("Opening the Site in 5 Seconds.");
                Thread.Sleep(5000);
                Process.Start("https://security.google.com/settings/security/apppasswords");
                Logger.Error("The Program is now freezed.");
                Thread.Sleep(Timeout.Infinite);
            }

            if (response.ContainsKey("Error"))
            {
                throw new GoogleException(response["Error"]);
            }

            //Todo: captcha/2fa implementation

            if (!response.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            var oauthResponse = client.PerformOAuth(response["Token"],
                                                    "audience:server:client_id:848232511240-7so421jotr2609rmqakceuu1luuq0ptb.apps.googleusercontent.com",
                                                    "com.nianticlabs.pokemongo",
                                                    "321187995bc7cdc2b5fc91b11a96e2baa8602c62");

            if (!oauthResponse.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            return(oauthResponse["Auth"]);
        }
Ejemplo n.º 5
0
        public async Task <string> GetAccessToken(bool ReAuthentification = true)
        {
            var client = new GPSOAuthClient(email, password);
            Dictionary <string, string> response = null;

            try{
                response = await client.PerformMasterLogin().ConfigureAwait(false);
            } catch (NullReferenceException) {
                return(null);
            }

            if (response.ContainsValue("NeedsBrowser"))
            {
                Logger.Error("Your Google Account uses 2FA. Create a Password for the Application here:");
                Logger.Error("https://security.google.com/settings/security/apppasswords");
                Logger.Error("And use that for Login with Google.");
                Logger.Error("Opening the Site in 5 Seconds.");
                Thread.Sleep(5000);
                Process.Start("https://security.google.com/settings/security/apppasswords");
                Logger.Error("The Program is now freezed.");
                Thread.Sleep(Timeout.Infinite);
            }

            if (response.ContainsKey("Error"))
            {
                Logger.Error(response["Error"]);
                return(null);
            }

            //Todo: captcha/2fa implementation

            if (!response.ContainsKey("Auth"))
            {
                Logger.Error("Auth String not found.");
                return(null);
            }

            var oauthResponse = await client.PerformOAuth(response["Token"],
                                                          Resources.GoogleAuth_AuthService,
                                                          Resources.GoogleAuth_App,
                                                          Resources.GoogleAuth_ClientSig).ConfigureAwait(false);

            if (!oauthResponse.ContainsKey("Auth"))
            {
                Logger.Error("Auth String not found.");
                return(null);
            }
            return(oauthResponse["Auth"]);
        }
Ejemplo n.º 6
0
#pragma warning disable 1998
        public async Task <AccessToken> GetAccessToken()
#pragma warning restore 1998
        {
            var client   = new GPSOAuthClient(_email, _password);
            var response = await client.PerformMasterLogin(GoogleLoginAndroidId);

            if (response.ContainsKey("Error"))
            {
                if (response.ContainsKey("Url"))
                {
                    await Launcher.LaunchUriAsync(new Uri(response["Url"]));
                }
                else
                {
                    throw new GoogleException(response["Error"]);
                }
            }

            //Todo: captcha/2fa implementation

            if (!response.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            var oauthResponse =
                await
                client.PerformOAuth(response["Token"], GoogleLoginService, GoogleLoginAndroidId, GoogleLoginApp,
                                    GoogleLoginClientSig);

            if (!oauthResponse.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            //return oauthResponse["Auth"];

            return(new AccessToken
            {
                Username = _email,
                Token = oauthResponse["Auth"],
                ExpiresUtc = DateTimeExtensions.GetDateTimeFromSeconds(int.Parse(oauthResponse["Expiry"])),
                AuthType = AuthType.Google
            });
        }
Ejemplo n.º 7
0
        public static string DoLogin(string username, string password)
        {
            GPSOAuthClient client = new GPSOAuthClient(username, password);
            Dictionary <string, string> response = client.PerformMasterLogin();

            if (response.ContainsKey("Error"))
            {
                if (response.ContainsValue("NeedsBrowser"))
                {
                    Console.WriteLine("Your Google Account uses 2Faktor Verification\n" +
                                      "You need to create a password on this site:\n" +
                                      "https://security.google.com/settings/security/apppasswords" + "\n" +
                                      "And use that one instead of the one you current use");
                    Console.ReadLine();
                }
                else if (response.ContainsValue("BadAuth"))
                {
                    Console.WriteLine("Credentials wrong!");
                }
                else
                {
                    throw new GoogleException(response["Error"]);
                }
            }

            if (!response.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            Dictionary <string, string> oauthResponse = client.PerformOAuth(response["Token"],
                                                                            "audience:server:client_id:848232511240-7so421jotr2609rmqakceuu1luuq0ptb.apps.googleusercontent.com",
                                                                            "com.nianticlabs.pokemongo",
                                                                            "321187995bc7cdc2b5fc91b11a96e2baa8602c62");

            if (!oauthResponse.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            return(oauthResponse["Auth"]);
        }
Ejemplo n.º 8
0
        public async Task <string> GetAccessToken()
        {
            if (String.IsNullOrEmpty(email) || String.IsNullOrEmpty(password))
            {
                throw new InvalidCredentialsException("Both email and password are required");
            }

            var client   = new GPSOAuthClient(email, password);
            var response = client.PerformMasterLogin();

            if (response.ContainsKey("Error"))
            {
                if (response["Error"] == "BadAuthentication")
                {
                    throw new GoogleException("Invalid Google credentials");
                }

                throw new GoogleException(response["Error"]);
            }

            //Todo: captcha/2fa implementation

            if (!response.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            var oauthResponse = client.PerformOAuth(response["Token"],
                                                    "audience:server:client_id:848232511240-7so421jotr2609rmqakceuu1luuq0ptb.apps.googleusercontent.com",
                                                    "com.nianticlabs.pokemongo",
                                                    "321187995bc7cdc2b5fc91b11a96e2baa8602c62");

            if (!oauthResponse.ContainsKey("Auth"))
            {
                throw new GoogleOfflineException();
            }

            return(oauthResponse["Auth"]);
        }