Armax / Pokemon-GO-node-api

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

Unable to authenticate with Google #241

Closed joselee closed 7 years ago

joselee commented 7 years ago

I'm trying to login with a Google account. PTC accounts are logging in successfully, but Google is failing with the following error message:

Error: 403 error from server at IncomingMessage.<anonymous> (/home/wsasd/software/pokemongo-api-node/node_modules/pokemon-go-node-api/node_modules/gpsoauthnode/oauth.js:61:23) at emitNone (events.js:72:20) at IncomingMessage.emit (events.js:166:7) at endReadableNT (_stream_readable.js:921:12) at nextTickCallbackWith2Args (node.js:442:9) at process._tickCallback (node.js:356:17)

This happens on .init(username, password, location, provider, callback).

monarchfish commented 7 years ago

how do u setting?

joselee commented 7 years ago

Here's how I'm logging in:

let pgo = require('pokemon-go-node-api');

let username = 'myemail@gmail.com';
let password = 'mygmailpassword'
let provider = 'google';
let location = {
    type: "coords",
    coords: {
        latitude: 37.779078,
        longitude: -122.420844,
        altitude: 10
    }
};

pgo.init(username, password, location, provider, function (err) {
    if (err) throw err; // <--Fails here!
    pgo.GetProfile((err, profile) => {
        if (err) throw err;
        console.log('[i] Username: ' + profile.username);
    });
}

Again, same code with 'ptc' as the provider and PTC username/password authenticates successfully.

joselee commented 7 years ago

Hi. Found the reason and fix at this issue: #94 The problem is that the Google account has 2-step verification, so using my actual gmail password didn't work. As @segura2010 commented in the issue linked above, I generated an app password for the google account, and used that for the 'password' variable to login. Instructions for generating a google app password: https://support.google.com/mail/answer/185833?hl=en