Skip to content

Commit 76a6b0d

Browse files
author
ekoleda
committed
Ensure that the expires_in field is handled as a number. Fixes #22.
1 parent cc379cf commit 76a6b0d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Service.gs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Service_.prototype.setTokenFormat = function(tokenFormat) {
7373
};
7474

7575
/**
76-
* Sets the additional HTTP headers that should be sent when retrieving or
76+
* Sets the additional HTTP headers that should be sent when retrieving or
7777
* refreshing the access token.
7878
* @param Object.<string,string> tokenHeaders A map of header names to values.
7979
* @return {Service_} This service, for chaining.
@@ -197,7 +197,7 @@ Service_.prototype.setPrivateKey = function(privateKey) {
197197
};
198198

199199
/**
200-
* Sets the issuer (iss) value to use for Service Account authorization.
200+
* Sets the issuer (iss) value to use for Service Account authorization.
201201
* If not set the client ID will be used instead.
202202
* @param {string} issuer This issuer value
203203
* @return {Service_} This service, for chaining.
@@ -208,7 +208,7 @@ Service_.prototype.setIssuer = function(issuer) {
208208
};
209209

210210
/**
211-
* Sets the subject (sub) value to use for Service Account authorization.
211+
* Sets the subject (sub) value to use for Service Account authorization.
212212
* @param {string} subject This subject value
213213
* @return {Service_} This service, for chaining.
214214
*/
@@ -505,7 +505,7 @@ Service_.prototype.isExpired_ = function(token) {
505505
if (!expires_in) {
506506
return false;
507507
} else {
508-
var expires_time = token.granted_time + expires_in;
508+
var expires_time = token.granted_time + Number(expires_in);
509509
var now = getTimeInSeconds_(new Date());
510510
return expires_time - now < Service_.EXPIRATION_BUFFER_SECONDS_;
511511
}
@@ -577,4 +577,4 @@ Service_.prototype.createJwt_ = function() {
577577
var signatureBytes = Utilities.computeRsaSha256Signature(toSign, this.privateKey_);
578578
var signature = Utilities.base64EncodeWebSafe(signatureBytes);
579579
return toSign + '.' + signature;
580-
};
580+
};

0 commit comments

Comments
 (0)