aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/clients/refresh.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/clients/refresh.js b/lib/clients/refresh.js
index b4a3930..7b9fde7 100644
--- a/lib/clients/refresh.js
+++ b/lib/clients/refresh.js
@@ -1,4 +1,6 @@
var request = require('request');
+var Timestamp = require('unix-timestamp');
+Timestamp.round = true;
var RefreshClient = function(refreshString) {
if (typeof refreshString !== 'string') {
@@ -6,7 +8,7 @@ var RefreshClient = function(refreshString) {
}
this._refreshToken = refreshString;
this._accessToken = '';
- this._accessTokenExpiration = Math.floor( new Date()/1000 );
+ this._accessTokenExpiration = Timestamp.now(-1);
};
RefreshClient.prototype._doRequest = function(url) {
@@ -47,7 +49,7 @@ RefreshClient.prototype._doRequest = function(url) {
RefreshClient.prototype._getAccessToken = function() {
var self = this;
return new Promise(function(fulfill, reject) {
- var currentTime = Math.floor( new Date()/1000 );
+ var currentTime = Timestamp.now();
if (self._accessTokenExpiration - currentTime <= 10) {
fulfill(self._refreshAccessToken());
} else {