Closed wiedmann closed 7 years ago
Note: the newest checkin also adds course and world to the player state decoding. Course is the value as it appears in the data - 3, 4, and 5 for Watopia, Richmond, and London, respectively. World is the value as it would be specified in prefs.xml (course - 2, currently).
This looks great. I'll get it merged in today.
(p.s. I've been on holiday for a few days - or else I'd have responded sooner).
The delay was lucky, actually, since my initial pull request was broken. I've double-checked that this latest version at least works with my telemetry code.
I tweaked the way the promise worked slightly (and also there was a tiny bug in the .world property), but it's now merged into master and released as v0.2.5
This change allows instantiating a ZwiftAccount with a refresh token instead of a username/password pair. The current lifetime of a refresh token is 30 days, so this is a convenient way to avoid prompting the user for a password as long as they use the app every 30 days. Note that a new refresh token is passed back every time the tokens are refreshed, so apps that store the token should retrieve the new one each time they run.
Note that this did change the return from getAccessToken.js to expose all of the data in the response. I wasn't sure if anyone was using that return directly. I can make it backward compatible if need be.
I also added the expiration times for the tokens to the return from the getAccessToken and getRefreshToken promises.