edwellbrook / node-tvdb

Node.js library for accessing TheTVDB API
https://edwellbrook.github.io/node-tvdb/
MIT License
66 stars 28 forks source link

Refresh JWT when required to stop it expiring #114

Open ianbarker opened 5 years ago

ianbarker commented 5 years ago

I've noticed that a long running app's token will expire. The API docs state that the token lasts for 24h so this PR should allow a refresh every 12 hours thus stopping it expiring.

edwellbrook commented 5 years ago

Hey Ian! Thanks for taking the time to put together this PR. I think this will make a great addition to the library! 😄

Could we implement this a slightly different way?

You can get the expiration date from the JWT by:

Cheers, and let me know if there's anything I can help with!

ianbarker commented 5 years ago

Ok, good idea. I'll make those changes and update the PR

ianbarker commented 5 years ago

Ok, I've updated the PR so that the token will refresh using the exp property of the JWT payload.