brianzhouzc / RocketBot

An automated Pokémon Go Bot
GNU General Public License v3.0
564 stars 315 forks source link

[Tip]New Google Auth Fix #440

Closed Fliperworld closed 8 years ago

Fliperworld commented 8 years ago

Since GetDeviceCode(), returns status 401 and a personal ClientId and ClientSecret throw AccessTokenExpiredException(), i found this 2 usefull links: https://github.com/Mila432/Pokemon_Go_API/blob/master/login.py and https://github.com/vemacs/GPSOAuthSharp Combining those 2 we can login with a google account:

using DankMemes.GPSOAuthSharp; 

comment lines 91 to 109:

  GoogleLogin.TokenResponseModel tokenResponse = null;

if (string.IsNullOrEmpty(_settings.GoogleRefreshToken) && string.IsNullOrEmpty(AccessToken))
            {
                var deviceCode = await GoogleLogin.GetDeviceCode();
                tokenResponse = await GoogleLogin.GetAccessToken(deviceCode);
                _accessToken = tokenResponse.id_token;
                ColoredConsoleWrite(ConsoleColor.White, $"Put RefreshToken in settings for direct login: {tokenResponse.refresh_token}");
                _settings.GoogleRefreshToken = tokenResponse.refresh_token;
                AccessToken = tokenResponse.refresh_token;
            }
            else
            {
                if (!string.IsNullOrEmpty(_settings.GoogleRefreshToken))
                    tokenResponse = await GoogleLogin.GetAccessToken(_settings.GoogleRefreshToken);
                else
                    tokenResponse = await GoogleLogin.GetAccessToken(AccessToken);
                _accessToken = tokenResponse.id_token;
}

and add those code on line 110:

                 string email = "YOUR GMAIL";
                 string password = "YOUR PASSWORD";
                   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"];
                          }

@sicheater compiled GPSOAuthSharp.dll

Strategic Breakpoints are at "if (_GPSOresponse.ContainsKey("Token"))" and " _accessToken = oauthResponse["Auth"];"

Important : this code is just a idea/adaptation of a code that i'm working on , try not store credentials in source code....A best approach is setting/getting those values from ISettings.cs and other related files

DoGoogleLogin.txt

Edit: you can add "GPSOAuthSharp.cs" directly to your Pokemon-Go-Rocket-API project

shaysht commented 8 years ago

@ItsAMaro I'm getting the same as you, don't worry haha

Pogob commented 8 years ago

@itsamaro nah, it's a thing that one of the official maintainers add to the source code. I thought i removed it though ("3) removed the 3 second delay between evolving pokemon (why does that exist? and why is it run before doing anything else)")...that's odd You kind of have to wait through it.

Update: uploading my version at the moment will copy link once done. See if that works for you. Hope you don't mind total xp/pokemon counter I added to it

Update 2: I believe the new problem is something with the connection Update 3: It's gone?

ItsAMaro commented 8 years ago

@Pogob I've waited 15 minutes and it still doesn't get the poke stops and stuff. I posted an image above of what I'm getting. Thanks for the help though.

Pogob commented 8 years ago

@ItsAMaro Yeah, thing is, the bot tries to evolve all your pokemon with a 3 second delay (rather than finding ones that have enough candy) which would cause that delay.

https://drive.google.com/open?id=0BzOKX4kYHDc8SVpWLXNXRVVweTA Update: try this

Seolhyun commented 8 years ago

@Pogob can u please help me noones personal settings is working for me

ItsAMaro commented 8 years ago

@Pogob Oh no I get that. Before that image I had run the Bot for 10 minutes and it had evolved everything that I had and discarded bad CP pokemon. The thing is now that it says Visiting 110 Pokestops it takes a long time to get to one, and well, then the thing that is on the image happened. I don't know why does it take so long to walk between PokeStops and doesn't catch wild pokemon on the road. That is my biggest issue right now.

shaysht commented 8 years ago

screenshot_4 Mine's just logging in and logging out instantly

Pogob commented 8 years ago

@shaysht Mine does the same. It calms down after a while

Seolhyun commented 8 years ago

Sigh, nothing works. no help. I guess im done with pokemon go

shaysht commented 8 years ago

@Pogob you sure?

Gangaji commented 8 years ago

@Seolhyun There are problems with the client currently be patient for the fix...