/// <summary> /// Login with a stored <see cref="AccessToken" />. /// </summary> /// <param name="accessToken"></param> /// <param name="password">The password is needed for reauthentication.</param> /// <param name="initialLatitude">The initial latitude you will spawn at after logging into PokémonGo.</param> /// <param name="initialLongitude">The initial longitude you will spawn at after logging into PokémonGo.</param> /// <returns></returns> public static Session GetSession(AccessToken accessToken, string password, double initialLatitude, double initialLongitude) { if (accessToken.IsExpired) { throw new Exception("AccessToken is expired."); } Log.Debug("Authenticated from cache."); return new Session(accessToken, password, new GeoCoordinate(initialLatitude, initialLongitude)); }
internal Session(AccessToken accessToken, string password, GeoCoordinate geoCoordinate) { AccessToken = accessToken; Password = password; Player = new Player(geoCoordinate); Map = new Map(); Templates = new Templates(); RpcClient = new RpcClient(this); _heartbeat = new HeartbeatDispatcher(this); }
private static void SaveAccessToken(AccessToken accessToken) { var fileName = Path.Combine(Environment.CurrentDirectory, "cache", $"{accessToken.Uid}.json"); File.WriteAllText(fileName, JsonConvert.SerializeObject(accessToken, Formatting.Indented)); }