Armax / Pokemon-GO-node-api

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

Auto logout after some time and/or session expire? #148

Open sameerkanda opened 8 years ago

sameerkanda commented 8 years ago

Instead of calling a.init() to login, i'm doing the following:

a.playerInfo.provider = provider;
a.playerInfo.accessToken = accessToken;
a.playerInfo.apiEndpoint = apiEndpoint;

where provider, accessToken, and apiEndpoint are variables saved in a filesystem. And then I use a.setLocation to set location.

This helps restarting node without having to keep logging in (might trigger a soft ban). This works fine for a few hours, and then I start to get 'No result' error from Pokemon GO server, regardless of the api call. I'm guessing the session expired or something? Any tips regarding this?

nathanaelnsmith commented 8 years ago

I solved this by checking for "No result" inside my heartbeat function and logging back in.

if(err) {
    console.log(err);
    if(err === "No result") {
        clearInterval(start);
        init();
    }
    return;
}