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

suhadi95 commented 8 years ago

btw thank you @Fliperworld :)

garyandtaz321 commented 8 years ago

Works!

Metin2Force commented 8 years ago

Client.css PLS :(

FreeHitss commented 8 years ago

can you show me SS? im really bad at this sorry. :( im getting a lot of errors

Tanuki33 commented 8 years ago

RE: https://github.com/DetectiveSquirrel/Pokemon-Go-Rocket-API/issues/440#issuecomment-235915410

TehPirat3 commented 8 years ago

For those with 2-step, I believe you can use https://security.google.com/settings/security/apppasswords to generate a password which doesn't require 2-step

nolzzz commented 8 years ago

@cyberpol86 lmao, the second idiot today who I saw login credentials :D

Metin2Force commented 8 years ago

19:21:42 ] Login Type: Google [19:21:42 ] Program Will Retart Every Hour! [19:21:42 ] Now opening www.Google.com/device and copying the 8 digit code to your clipboard [19:21:42 ] Argument Null Refference - Restarting [19:21:42 ] Login Type: Google [19:21:42 ] Program Will Retart Every Hour!

Thank you Client.cs @cyberpol86 Problem..

cyberpol86 commented 8 years ago

@nolzzz why ?

Metin2Force commented 8 years ago

GPSOAuthSharp.dll Sendme Please.

FreeHitss commented 8 years ago

cant compile mine :( wwwwwwwwwwwww

nolzzz commented 8 years ago

@cyberpol86 I meeant metiin2force...

Fliperworld commented 8 years ago

@FreeHitss right click on Solution Explorer/ References , then Add reference ...and add GPSOAuthSharp.dll ...

nolzzz commented 8 years ago

Is there a more detailed guide to this? Im so lost

Metin2Force commented 8 years ago

https://github.com/Mila432/Pokemon_Go_API/blob/master/login.py and https://github.com/vemacs/GPSOAuthSharp

How do we combine the two?

FreeHitss commented 8 years ago

@Fliperworld thanks! sir bless you ! :D

nolzzz commented 8 years ago

@Metin2Force same here. Really need someone to write a step by step guide :(

FreeHitss commented 8 years ago

one last thing im stuck into this. cant login? trying ctrl+v no code showing. wwwwwwwwwwwww

FreeHitss commented 8 years ago

any solution for this?

suhadi95 commented 8 years ago

@FreeHitss same like me, your account have softban, so wait 30-60 min :)

FreeHitss commented 8 years ago

@suhadi95 i tried logging in on nox and im getting pokemons

suhadi95 commented 8 years ago

maybe can help, thanks to @Fliperworld, this file just Build and ready to use...

Started

https://drive.google.com/file/d/0B5dYBEjrVNDZWkFKS1BmQVBSZUk/view?usp=sharing

help

suhadi95 commented 8 years ago

@FreeHitss i don't know, but i like that +sry bad eng

FreeHitss commented 8 years ago

@suhadi95 request sent!

FreeHitss commented 8 years ago

its working now ty all!

cyberpol86 commented 8 years ago

@suhadi95 request sent!

Seolhyun commented 8 years ago

I'm gonna need help with this. Im at summer school. Can someone help me when I get back

cyberpol86 commented 8 years ago

@suhadi95 request send file

Pogob commented 8 years ago

Not sure if this helps anyone, but since you guys are all requesting the file, I made my own copy and it should work without any requests. https://drive.google.com/file/d/0BzOKX4kYHDc8QUY2QVJBYlB1U3c/view?usp=sharing

I've made 3 changes from the original code: 1) get the new google auth in 2) change the settings form to actually save the password/username for google aswell. 3) removed the 3 second delay between evolving pokemon (why does that exist? and why is it run before doing anything else)

Basically you can just download this, run it, edit the password/username and everything should be gucci.

lex095 commented 8 years ago

@suhadi95 Open access , pls

miazmi commented 8 years ago

@suhadi95 request sent! accept pls :(

CryptoBackroom commented 8 years ago

@Pogob his code works. open settings window from bot before you start and put in your google login info.

suhadi95 commented 8 years ago

sry for acces google drive, hehe now try again..

suhadi95 commented 8 years ago

try apps from @Pogob , work and simple :+1: :)

ItsAMaro commented 8 years ago

@Pogob I tried using your app but it stays like this (see image) and it doesn't copy the 8-digit to clipboard. Any ideas? image

dexter323i commented 8 years ago

@ItsAMaro I had the same issue, when my phone was also running the Pokémon Go app. You can only use this game from one device at a time. And don't jump big distances in a short period of a time, or you will be soft banned. (You do not find pokémons, and get nothing from Poké Stops)

ItsAMaro commented 8 years ago

@dexter323i I am not in both devices at the same time, and I'm starting the bot at the same location. Something weird happens haha :( but well, the only thing is wait for a fix or something. I appreciate the effort people put into this.

Seolhyun commented 8 years ago

Can Someone Please help me with this

shaysht commented 8 years ago

ArgumentOutOfRangeException - Restarting?

Seolhyun commented 8 years ago

Lmao this guide is so useless. How the hell do you compile it and stuff.

dexter323i commented 8 years ago

@shaysht exactly the same to me. :( With both google and ptc login. http://ispokemongodownornot.com/ says all servers are ok, login from phone is also ok.

This solution worked for 4 or 5 hours to me. Now it went wrong, and nothing works. :( Can anybody else use this Rocket API right now?

shaysht commented 8 years ago

@dexter323i same issue was happening with other bots, something server sided? QuickSpin (to get unbanned) worked the 1 time I tried out of hundreds but still throws up the same error also

Gangaji commented 8 years ago

@Seolhyun Just download @suhadi95's or @Pogob's clients.

Pogob commented 8 years ago

@ItsAMaro I'll look into it. I left mine running for 3 hours and it stopped and didnt retry. Not quite familiar with the code just yet, but I will look deeper into this.

Just tested @dexter323i 's suggestion and it's not due to multiple devices running at the same time, nor is it due to wrong credentials. Also, it wont actually copy any code, we can't do that anymore, have to login manually

Pogob commented 8 years ago

@shaysht @dexter323i what's the actual error you get? Or does it just not go past the green text of logging in?

shaysht commented 8 years ago

screenshot_3 This, with every bot thats managed to get through the google auth thing, so it's not that.

Pogob commented 8 years ago

Yeah, that seems like an account in use issue @shaysht

shaysht commented 8 years ago

@Pogob works fine on mobile though?

ItsAMaro commented 8 years ago

@Pogob I don't capture any pokemon or even go to a pokestop. It has been like this for a while now. I restarted it and it doesn't do anything. I am NOT Softbanned or anything, when I log into the game manually I can catch pokemon and get Pokestops. image

image

UPDATE: Okay so it got a Pokestop and I got this. How much km/h should I give it. I have it in 7, maybe is that?

image

shaysht commented 8 years ago

I have lucky egg enabled, could be that? Pretty stupid but I accidentally enabled it and that error has only occured since then. Also I'm playing it fine on mobile so I'm not banned, not soft-banned either.