Armax / Pokemon-GO-node-api

Pokemon GO api node.js library
MIT License
875 stars 198 forks source link

Add initWithGoogleAuth for signing in with Google AuthorizationCode #230

Closed LASkuma closed 6 years ago

LASkuma commented 7 years ago

When you deploy products on a server, usually clients cannot login with their email and password since it would be blocked by google as suspicious logins. It's also lack of safety if SSL is not implemented on the server. By adding this feature, developers can put this link onto their app and let user provide the authorization code returned by google to login into their applications.

https://accounts.google.com/o/oauth2/auth?client_id=848232511240-73ri3t7plvk96pj4f85uj8otdat2alem.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=openid%20email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email

marvi14 commented 7 years ago

Could you manage to make this work? beacuse i'm unable to get the correct ApiEndpoint with the token generated from your link

LASkuma commented 7 years ago

It works properly here. Are you using it locally or on your server?

marvi14 commented 7 years ago

I copy-paste your link in the browser, log in with my account, copy-paste the generated token and replace in poke.io.js that token instead of calling self.GetAccessToken and getting the token from the callback. If i use the google login of the library, the self.GetApiEndpoint works fine.

Im running the node server locally

LASkuma commented 7 years ago

You cannot simply replace the access token with the AuthCode because they are different. Instead, you should call self.initWithGoogleAuthCode.

marvi14 commented 7 years ago

Oh, so in logins.js, i have to replace data.masterToken for the token of the access token that i already got from google?

LASkuma commented 7 years ago

You don't need to change anything. Just call pokeio.initWithGooleAuthCode(yourToken, yourlocation, callback). Everything, including access token and api endpoint, will be setup automatically for you.

marvi14 commented 7 years ago

Ohhhh my bad, i have the poke.io.js wich not has your method initWithGooleAuthCode implemented. I will replace it. Ty!!

LASkuma commented 7 years ago

You can try my fork of this library. https://github.com/LASkuma/Pokemon-GO-node-api

marvi14 commented 7 years ago

I will, thank you very much!

marvi14 commented 7 years ago

Hey, Hi again. Did you manage to renew the token when the user logs in with google? i'm having a hard time with this. Renewing token with username and password is easy, but with google is not, as it would requiere the user to relog and generate a new AuthToken

LASkuma commented 7 years ago

Actually it's much easier than username/password token refreshing. I can implement it when I have time if you want.

marvi14 commented 7 years ago

Don't worry...i end up sending username and password in every request to init the poki.io instance

marvi14 commented 7 years ago

@LASkuma were u able to deploy the project somewhere? i'm having a hard time with this...neither AWS or Heroku seems to work

LASkuma commented 7 years ago

I use krypt.

Sent from my iPhone

On Aug 31, 2016, at 09:27, marvi14 notifications@github.com wrote:

@LASkuma were u able to deploy the project somewhere? i'm having a hard time with this...neither AWS or Heroku seems to work

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

marvi14 commented 7 years ago

@LASkuma will give it a try. Thank you!

marvi14 commented 7 years ago

@LASkuma there´s any guide or documentation to deploy to Krypt? because i didn't see anything. In addition, there is a free plan there? or only paid plans?

LASkuma commented 7 years ago

There are only paid plans. You can deploy in the same way as AWS.

Sent from my iPhone

On Aug 31, 2016, at 11:09, marvi14 notifications@github.com wrote:

@LASkuma there´s any guide or documentation to deploy to Krypt? because i didn't see anything. In addition, there is a free plan there? or only paid plans?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

marvi14 commented 7 years ago

@LASkuma great! Thank you