PokemonGoBot icon indicating copy to clipboard operation
PokemonGoBot copied to clipboard

Google Token Expiration

Open Lenovotro opened this issue 10 years ago • 10 comments

Is it possible to create a script that'll pull the token request from a google sign-in and automatically "allow permission"? Unless anyone else know show to bypass the 1 hour token expiration. Rather annoying when you want to leave it on. ;)

Lenovotro avatar Jul 23 '16 17:07 Lenovotro

I know that it is possible to renew the OAuth token, and sometimes even allow for no intervention at all(besides entering email/pass). The Python bot does this without having to enter a code. I'm looking into how this is done(and hopefully others are too), and seeing if I can figure something about for this project.

KyleBoyer avatar Jul 23 '16 18:07 KyleBoyer

@KyleBoyer Perfect! Let me know what you find.

Lenovotro avatar Jul 23 '16 18:07 Lenovotro

Googling a bit on the issue too, it appears that the first time you enter the code on the google.com/device page, a refresh token is also provided. Once the regular token(not refresh token) expires, you have to use the refresh token to fetch a new regular token. So it is vital to store this refresh token(maybe even in the config file) to fetch new tokens.

KyleBoyer avatar Jul 23 '16 18:07 KyleBoyer

"So i finally figured out how to do this. The basic idea is that you have the token you get the first time you ask for authentication. This first token has a refresh token. The first original token expires after an hour. After an hour you have to use the refresh token from the first token to get a new usable token. You use $client->refreshToken($refreshToken) to retrieve a new token. I will call this "temp token." You need to store this temp token as well because after an hour it expires as well and note it does not have a refresh token associated with it. In order to get a new temp token you need to use the method you used before and use the first token's refreshtoken. I have attached code below, which is ugly, but im new at this..."

Quote from https://stackoverflow.com/questions/9241213/how-to-refresh-token-with-google-api-client

KyleBoyer avatar Jul 23 '16 18:07 KyleBoyer

Report this here https://github.com/Grover-c13/PokeGOAPI-Java. Also check if there's already a discussion about it first.

mluigi avatar Jul 23 '16 18:07 mluigi

@KyleBoyer Could be on to something there!

Lenovotro avatar Jul 23 '16 19:07 Lenovotro

As said, this is an upstream problem; closing this issue

mluigi avatar Jul 23 '16 20:07 mluigi

When this is merged it should be fixed https://github.com/Grover-c13/PokeGOAPI-Java/pull/165

jabbink avatar Jul 23 '16 21:07 jabbink

@jabbink when do you expect a merge?

Lenovotro avatar Jul 23 '16 23:07 Lenovotro

Grover-c13/PokeGOAPI-Java#165 is merged so it works here as well now

jabbink avatar Jul 24 '16 16:07 jabbink