PokeGOAPI-Java icon indicating copy to clipboard operation
PokeGOAPI-Java copied to clipboard

Persisting Auth info

Open Aphoh opened this issue 10 years ago • 14 comments

There is currently no way to persist auth info. This is useful for apps where a user will login and then use and exit the app, as the next time they open the app their auth info can be retrieved from disk instead of requiring them to log in again.

Aphoh avatar Jul 20 '16 09:07 Aphoh

It shouldn't be done on the API/SDK/Library side. ❌

quentin23soleil avatar Jul 20 '16 09:07 quentin23soleil

So you think logging in should be in the API, but refreshing an earlier token coming from inside the API should be done by another dev themselves?

jabbink avatar Jul 20 '16 09:07 jabbink

@jabbink refreshing the token is not what @Aphoh is asking. My understanding of this issue is "store the username/password on the disk". <- this should be done in the client.

quentin23soleil avatar Jul 20 '16 09:07 quentin23soleil

Oh, from the discussion we had in Slack about this, I think @Aphoh means that you can give a refresh token (stored by another application, not this library) and this API will refresh it, so it doesn't have to fully login again with username/password.

@Aphoh, please clarify what you mean <3

jabbink avatar Jul 20 '16 09:07 jabbink

Oh, that would make sense and would be good to have IMHO 😄

quentin23soleil avatar Jul 20 '16 09:07 quentin23soleil

I meant there must be a way to reconstruct/refresh the AuthInfo class from a token. The storing should be done by the client.

Aphoh avatar Jul 20 '16 09:07 Aphoh

Added this method wit my PR, should be enough to refresh the AuthInfo used by the client.

vmarchaud avatar Jul 21 '16 13:07 vmarchaud

What was your idea on getting that new, valid AuthInfo without using a username and password?

jabbink avatar Jul 21 '16 13:07 jabbink

This is temporary method to let user that know how to get a valid AuthInfo refresh the AuthInfo that the request handler use. Tbh i forgot that i had added these line, was justing for testing at the time.

vmarchaud avatar Jul 21 '16 14:07 vmarchaud

... Looked into other projects how they do this and they store the expiry date for the ticket, and when it expires, re login with username/password...

Will look into the network traffic of the official app to see how that one does it.

jabbink avatar Jul 21 '16 15:07 jabbink

Also the refresh token expires after 30 mins ..

davidmann4 avatar Jul 21 '16 19:07 davidmann4

Looked into the traffic of the official app (only PTC) and can't seem to see how it gets the initial token now...

jabbink avatar Jul 21 '16 20:07 jabbink

OAUTH login shouldn't need your credentials ever - the Google login doesn't actually use what you pass it. You provide the credentials when you follow the link and authenticate the "device" with Google.

apottere avatar Jul 22 '16 14:07 apottere

&access_type=offline in GoogleLogin.java:48 to include the refresh token in the response.

mmastika avatar Jul 22 '16 17:07 mmastika