internal async Task <Dictionary <string, string> > Login(string username, string password) { var googleClient = new GPSOAuthClient(username, password, GOOGLE_LOGIN_ANDROID_ID); var masterLoginResponse = await googleClient.PerformMasterLogin(); if (masterLoginResponse.ContainsKey("Error")) { if (masterLoginResponse["Error"].Equals("NeedsBrowser")) { throw new GoogleLoginException($"You have to log into an browser with the email '{username}'."); } throw new GoogleLoginException($"Google returned an error message: '{masterLoginResponse["Error"]}'"); } if (!masterLoginResponse.ContainsKey("Token")) { throw new GoogleLoginException("Token was missing from master login response."); } var oauthResponse = await googleClient.PerformOAuth(masterLoginResponse["Token"], GOOGLE_LOGIN_SERVICE, GOOGLE_LOGIN_APP, GOOGLE_LOGIN_CLIENT_SIG); if (!oauthResponse.ContainsKey("Auth")) { throw new GoogleLoginException("Auth token was missing from oauth login response."); } return(oauthResponse); }
/// <summary> /// Retrieves an <see cref="AccessToken"/> by logging into through the Google Play Services OAuth. /// </summary> /// <returns>Returns an <see cref="AccessToken"/>.</returns> public async Task <AccessToken> GetAccessToken(string useragent, string language) { var googleClient = new GPSOAuthClient(_username, _password); var masterLoginResponse = await googleClient.PerformMasterLogin(); if (masterLoginResponse.ContainsKey("Error")) { if (masterLoginResponse["Error"].Equals("NeedsBrowser")) { throw new GoogleLoginException($"You have to log into an browser with the email '{_username}'."); } throw new GoogleLoginException($"Google returned an error message: '{masterLoginResponse["Error"]}'"); } if (!masterLoginResponse.ContainsKey("Token")) { throw new GoogleLoginException("Token was missing from master login response."); } var oauthResponse = await googleClient.PerformOAuth(masterLoginResponse["Token"], Constants.GoogleAuthService, Constants.GoogleAuthApp, Constants.GoogleAuthClientSig); if (!oauthResponse.ContainsKey("Auth")) { throw new GoogleLoginException("Auth token was missing from oauth login response."); } return(new AccessToken { Username = _username, Token = oauthResponse["Auth"], Expiry = TimeUtil.GetDateTimeFromSeconds(int.Parse(oauthResponse["Expiry"])), ProviderID = ProviderId }); }
public static void Main(string[] args) { var email = Environment.GetEnvironmentVariable("GOOGLE_USERNAME") ?? ""; var password = Environment.GetEnvironmentVariable("GOOGLE_PASSWORD") ?? ""; var googleClient = new GPSOAuthClient(email, password); var masterLoginResponse = googleClient.PerformMasterLogin().Result; 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"], "audience:server:client_id:848232511240-7so421jotr2609rmqakceuu1luuq0ptb.apps.googleusercontent.com", "com.nianticlabs.pokemongo", "321187995bc7cdc2b5fc91b11a96e2baa8602c62").Result; if (!oauthResponse.ContainsKey("Auth")) { throw new Exception("Auth token was missing from oauth login response."); } Console.WriteLine("Authenticated through Google."); Console.ReadLine(); }
/// 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 }); }
#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"]); }
static void Main(string[] args) { Console.WriteLine("Google account email: "); string email = Console.ReadLine(); Console.WriteLine("Password: "******""; ConsoleKeyInfo info = Console.ReadKey(true); while (info.Key != ConsoleKey.Enter) { if (info.Key != ConsoleKey.Backspace) { Console.Write("*"); password += info.KeyChar; } else if (info.Key == ConsoleKey.Backspace) { if (!string.IsNullOrEmpty(password)) { password = password.Substring(0, password.Length - 1); int pos = Console.CursorLeft; Console.SetCursorPosition(pos - 1, Console.CursorTop); Console.Write(" "); Console.SetCursorPosition(pos - 1, Console.CursorTop); } } info = Console.ReadKey(true); } Console.WriteLine(); GPSOAuthClient client = new GPSOAuthClient(email, password); Dictionary <string, string> response = client.PerformMasterLogin(); string json = JsonConvert.SerializeObject(response, Formatting.Indented); Console.WriteLine(json); if (response.ContainsKey("Token")) { string token = response["Token"]; Dictionary <string, string> oauthResponse = client .PerformOAuth(token, "sj", "com.google.android.music", "38918a453d07199354f8b19af05ec6562ced5788"); string oauthJson = JsonConvert.SerializeObject(oauthResponse, Formatting.Indented); Console.WriteLine(oauthJson); } else { Console.WriteLine("MasterLogin failed (check credentials)"); } Console.ReadLine(); }
#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"], Expiry = DateTimeExtensions.GetDateTimeFromSeconds(int.Parse(oauthResponse["Expiry"])), AuthType = AuthType.Google }); }
public async Task <bool> Login(string Username, string Password) { bool loginSuccessful = true; var client = new GPSOAuthClient(Username, Password); Dictionary <String, String> res = null; try { res = await client.PerformMasterLogin("5453EDB5AAC9"); } catch (Exception e) { loginSuccessful = false; return(loginSuccessful); } while (res.Count != 9) { try { res = await client.PerformMasterLogin("5453EDB5AAC9"); } catch (Exception e) { loginSuccessful = false; return(loginSuccessful); } } //token oauth2rt_1/4y6xyPZ14pJmjUGGk2HrRecdM9Ing36lFxZQXN1Yrqk //auth DQAAABQBAAAtxzjhseQwMlLFVCrn7EEtSISt9C4UDzksepnCxmDrvUhm1QrU6_HLhFzixL_v2zw3fFiDA3sHzhWBhezbBOYYiKicSZecHXCI31CG12QMTSNQ10HTW9d6ghVjDAsxSVDuVgc7D5zh5FqZCDuLS-xBiin93WJ0Genq5EKnJIYYZaRL10yru4lJRik7JurPGBxnaLxsiWNnjnEJ75ikptA8thVxneGyGzkd4vh-V6YVlu3VFmJMrS2MhUaXEn8vG5oejfUpSvmYlQLI_ZqX02JmI5i353vwtABO_6AaqAUZ72I05oU5nzysE5xPFegPbfC8CF6EBzy5bkYQji5jZ-6qIbdkM1U8I1alUpeYIB1Uksl5L3psqFAOJupoXc86qiw //var token = "oauth2rt_1/4y6xyPZ14pJmjUGGk2HrRecdM9Ing36lFxZQXN1Yrqk"; //var authToken1 = "DQAAABQBAAAtxzjhseQwMlLFVCrn7EEtSISt9C4UDzksepnCxmDrvUhm1QrU6_HLhFzixL_v2zw3fFiDA3sHzhWBhezbBOYYiKicSZecHXCI31CG12QMTSNQ10HTW9d6ghVjDAsxSVDuVgc7D5zh5FqZCDuLS-xBiin93WJ0Genq5EKnJIYYZaRL10yru4lJRik7JurPGBxnaLxsiWNnjnEJ75ikptA8thVxneGyGzkd4vh-V6YVlu3VFmJMrS2MhUaXEn8vG5oejfUpSvmYlQLI_ZqX02JmI5i353vwtABO_6AaqAUZ72I05oU5nzysE5xPFegPbfC8CF6EBzy5bkYQji5jZ-6qIbdkM1U8I1alUpeYIB1Uksl5L3psqFAOJupoXc86qiw"; var token = res["Token"]; res = await client.PerformOAuth("5453EDB5AAC9", token, "sj", "com.google.android.music", "38918a453d07199354f8b19af05ec6562ced5788"); var authToken1 = res["Auth"]; authToken = authToken1; loginSuccessful = true; return(loginSuccessful); }
/// <summary> /// /// </summary> /// <returns></returns> public async Task <AuthenticatedUser> GetAuthenticatedUser() { var client = new GPSOAuthClient(Username, Password); var response = await client.PerformMasterLogin(Constants.GoogleOAuthAndroidId); 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"], Constants.GoogleOAuthService, Constants.GoogleOAuthAndroidId, Constants.GoogleOAuthApp, Constants.GoogleOAuthClientSig); if (!oauthResponse.ContainsKey("Auth")) { throw new GoogleOfflineException(); } return(new AuthenticatedUser { Username = Username, AccessToken = oauthResponse["Auth"], ExpiresUtc = DateTimeOffset.FromUnixTimeSeconds(long.Parse(oauthResponse["Expiry"])).UtcDateTime, ProviderType = AuthenticationProviderTypes.Google }); }
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"]; } }
public async Task<bool> Login(string Username, string Password) { bool loginSuccessful = true; var client = new GPSOAuthClient(Username, Password); Dictionary<String, String> res = null; try { res = await client.PerformMasterLogin("5453EDB5AAC9"); } catch (Exception e) { loginSuccessful = false; return loginSuccessful; } while (res.Count != 9) { try { res = await client.PerformMasterLogin("5453EDB5AAC9"); } catch (Exception e) { loginSuccessful = false; return loginSuccessful; } } //token oauth2rt_1/4y6xyPZ14pJmjUGGk2HrRecdM9Ing36lFxZQXN1Yrqk //auth DQAAABQBAAAtxzjhseQwMlLFVCrn7EEtSISt9C4UDzksepnCxmDrvUhm1QrU6_HLhFzixL_v2zw3fFiDA3sHzhWBhezbBOYYiKicSZecHXCI31CG12QMTSNQ10HTW9d6ghVjDAsxSVDuVgc7D5zh5FqZCDuLS-xBiin93WJ0Genq5EKnJIYYZaRL10yru4lJRik7JurPGBxnaLxsiWNnjnEJ75ikptA8thVxneGyGzkd4vh-V6YVlu3VFmJMrS2MhUaXEn8vG5oejfUpSvmYlQLI_ZqX02JmI5i353vwtABO_6AaqAUZ72I05oU5nzysE5xPFegPbfC8CF6EBzy5bkYQji5jZ-6qIbdkM1U8I1alUpeYIB1Uksl5L3psqFAOJupoXc86qiw //var token = "oauth2rt_1/4y6xyPZ14pJmjUGGk2HrRecdM9Ing36lFxZQXN1Yrqk"; //var authToken1 = "DQAAABQBAAAtxzjhseQwMlLFVCrn7EEtSISt9C4UDzksepnCxmDrvUhm1QrU6_HLhFzixL_v2zw3fFiDA3sHzhWBhezbBOYYiKicSZecHXCI31CG12QMTSNQ10HTW9d6ghVjDAsxSVDuVgc7D5zh5FqZCDuLS-xBiin93WJ0Genq5EKnJIYYZaRL10yru4lJRik7JurPGBxnaLxsiWNnjnEJ75ikptA8thVxneGyGzkd4vh-V6YVlu3VFmJMrS2MhUaXEn8vG5oejfUpSvmYlQLI_ZqX02JmI5i353vwtABO_6AaqAUZ72I05oU5nzysE5xPFegPbfC8CF6EBzy5bkYQji5jZ-6qIbdkM1U8I1alUpeYIB1Uksl5L3psqFAOJupoXc86qiw"; var token = res["Token"]; res = await client.PerformOAuth("5453EDB5AAC9", token, "sj", "com.google.android.music", "38918a453d07199354f8b19af05ec6562ced5788"); var authToken1 = res["Auth"]; authToken = authToken1; loginSuccessful = true; return loginSuccessful; }
private Task <Dictionary <string, string> > GetOauthResponse(GPSOAuthClient googleClient) { return(googleClient.PerformOAuth(_token, "oauth2:https://www.googleapis.com/auth/memento https://www.googleapis.com/auth/reminders", "com.google.android.keep", "38918a453d07199354f8b19af05ec6562ced5788")); }