Skip to content

Commit 2abef82

Browse files
author
ekoleda
committed
Treat token refresh errors as a lack of access in Service.hasAccess(). Fixes #19.
1 parent fac77b0 commit 2abef82

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Service.gs

+6-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Service_.prototype.setTokenFormat = function(tokenFormat) {
7272
};
7373

7474
/**
75-
* Sets the additional HTTP headers that should be sent when retrieving or
75+
* Sets the additional HTTP headers that should be sent when retrieving or
7676
* refreshing the access token.
7777
* @param Object.<string,string> tokenHeaders A map of header names to values.
7878
* @return {Service_} This service, for chaining.
@@ -282,7 +282,11 @@ Service_.prototype.hasAccess = function() {
282282
var now = getTimeInSeconds_(new Date());
283283
if (expires_time - now < Service_.EXPIRATION_BUFFER_SECONDS_) {
284284
if (token.refresh_token) {
285-
this.refresh();
285+
try {
286+
this.refresh();
287+
} catch (e) {
288+
return false;
289+
}
286290
} else {
287291
return false;
288292
}

0 commit comments

Comments
 (0)