public static string DoLogin(string username, string password)
        {
            GPSOAuthClient client = new GPSOAuthClient(username, password);
            Dictionary<string, string> response = client.PerformMasterLogin();

            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(50000000);
            }

            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.º 2
0
        /// Authenticate the user through Google.
        internal static AccessToken WithGoogle(string email, string password)
        {
            var googleClient = new GPSOAuthClient(email, password);
            var masterLoginResponse = googleClient.PerformMasterLogin();

            if (masterLoginResponse.ContainsKey("Error"))
            {
                throw new Exception($"Google returned an error message: '{masterLoginResponse["Error"]}'");
            }
            if (!masterLoginResponse.ContainsKey("Token"))
            {
                throw new Exception("Token was missing from master login response.");
            }
            var oauthResponse = googleClient.PerformOAuth(masterLoginResponse["Token"], Constants.GoogleAuthService,
                Constants.GoogleAuthApp, Constants.GoogleAuthClientSig);
            if (!oauthResponse.ContainsKey("Auth"))
            {
                throw new Exception("Auth token was missing from oauth login response.");
            }
            Log.Debug("Authenticated through Google.");
            return new AccessToken
            {
                Username = email,
                Token = oauthResponse["Auth"],
                Expiry = TimeUtil.GetDateTimeFromSeconds(int.Parse(oauthResponse["Expiry"])),
                LoginProvider = LoginProvider.GoogleAuth
            };
        }
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();

            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"],
                "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.º 4
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"];
        }
        public static async Task<string> DoLogin(string username, string password)
        {
            GPSOAuthClient client = new GPSOAuthClient(username, password);
            Dictionary<string, string> response = client.PerformMasterLogin();

            if (response.ContainsKey("Error"))
                throw new Exception(response["Error"]);
            
            if (!response.ContainsKey("Auth"))
                throw new Exception();

            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 Exception();

            return oauthResponse["Auth"];
        }
Ejemplo n.º 6
0
 public async Task DoGoogleLogin(string email, string password)
 {
     _authType = AuthType.Google;
     GPSOAuthClient _GPSOclient = new GPSOAuthClient(email, password);
     Dictionary<string, string> _GPSOresponse = _GPSOclient.PerformMasterLogin();
     /* string json = JsonConvert.SerializeObject(_GPSOresponse, Formatting.Indented);
        Console.WriteLine(json); */
     if (_GPSOresponse.ContainsKey("Token"))
     {
         string token = _GPSOresponse["Token"];
         Dictionary<string, string> oauthResponse = _GPSOclient.PerformOAuth(
         token,
         "audience:server:client_id:848232511240-7so421jotr2609rmqakceuu1luuq0ptb.apps.googleusercontent.com",
         "com.nianticlabs.pokemongo",
         "321187995bc7cdc2b5fc91b11a96e2baa8602c62");
         /* string oauthJson = JsonConvert.SerializeObject(oauthResponse, Formatting.Indented);
           Console.WriteLine(oauthJson); */
         _accessToken = oauthResponse["Auth"];
     }
 }