kient
kient copied to clipboard
Refresh token support?
It would be cool if when you set the auth token if you could also pass in the refresh token- like so:
kient.setAuthToken({ // This would still support arg1 as the authToken ofc-
auth: "auth token",
refresh: "refresh token",
expires: "expires date/seconds" // // Maybe the expireTime should be a date or just the seconds- or support for both!-
});
kient.setClient("client id", "client secret"); // allows refreshing of token
Then the module would auto-update the token when required- or if the request fails- it would then try to update the token
When a token is updated- a event should be fired- KIENT_TOKEN_UPDATE which should include the new token and refresh token- (to be saved in a file)- if the expireTime above can be a date, then the returned "expire time" should also be a date in the event data
If this sounds OK- I could try to make this a PR.