Skip to content

Commit 2ea1833

Browse files
committed
Fix issue with refreshing token when client_secret is not set
1 parent f57c727 commit 2ea1833

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

dist/OAuth2.gs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,6 @@ Service_.prototype.ensureExpiresAtSet_ = function(token) {
759759
Service_.prototype.refresh = function() {
760760
validate_({
761761
'Client ID': this.clientId_,
762-
'Client Secret': this.clientSecret_,
763762
'Token URL': this.tokenUrl_
764763
});
765764

src/Service.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,6 @@ Service_.prototype.ensureExpiresAtSet_ = function(token) {
666666
Service_.prototype.refresh = function() {
667667
validate_({
668668
'Client ID': this.clientId_,
669-
'Client Secret': this.clientSecret_,
670669
'Token URL': this.tokenUrl_
671670
});
672671

test/test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,31 @@ describe('Service', () => {
387387
done();
388388
});
389389

390+
it('should refresh token granted for PKCE', (done) => {
391+
var token = {
392+
granted_time: 100,
393+
expires_in: 0,
394+
refresh_token: 'bar'
395+
};
396+
var properties = new MockProperties({
397+
'oauth2.test': JSON.stringify(token)
398+
});
399+
400+
mocks.UrlFetchApp.resultFunction = () => JSON.stringify({
401+
access_token: Math.random().toString(36)
402+
});
403+
404+
OAuth2.createService('test')
405+
.setClientId('test')
406+
.setTokenUrl('http://www.example.com')
407+
.setPropertyStore(properties)
408+
.refresh();
409+
410+
var storedToken = JSON.parse(properties.getProperty('oauth2.test'));
411+
assert.equal(storedToken.refresh_token, 'bar');
412+
done();
413+
});
414+
390415
it('should retain refresh expiry', () => {
391416
const NOW_SECONDS = OAuth2.getTimeInSeconds_(new Date());
392417
const ONE_HOUR_AGO_SECONDS = NOW_SECONDS - 360;

0 commit comments

Comments
 (0)