diff --git a/dist/OAuth2.gs b/dist/OAuth2.gs index adf3bb84..ce97757c 100644 --- a/dist/OAuth2.gs +++ b/dist/OAuth2.gs @@ -759,7 +759,6 @@ Service_.prototype.ensureExpiresAtSet_ = function(token) { Service_.prototype.refresh = function() { validate_({ 'Client ID': this.clientId_, - 'Client Secret': this.clientSecret_, 'Token URL': this.tokenUrl_ }); diff --git a/src/Service.js b/src/Service.js index 68bd3e7f..e7527fe1 100644 --- a/src/Service.js +++ b/src/Service.js @@ -666,7 +666,6 @@ Service_.prototype.ensureExpiresAtSet_ = function(token) { Service_.prototype.refresh = function() { validate_({ 'Client ID': this.clientId_, - 'Client Secret': this.clientSecret_, 'Token URL': this.tokenUrl_ }); diff --git a/test/test.js b/test/test.js index 1e8317f7..fe7aca71 100644 --- a/test/test.js +++ b/test/test.js @@ -387,6 +387,35 @@ describe('Service', () => { done(); }); + it('should refresh token granted for PKCE', () => { + const NOW_SECONDS = OAuth2.getTimeInSeconds_(new Date()); + const ONE_HOUR_AGO_SECONDS = NOW_SECONDS - 360; + var token = { + granted_time: ONE_HOUR_AGO_SECONDS, + expires_in: 100, + refresh_token: 'bar', + refresh_token_expires_in: 720 + }; + var properties = new MockProperties({ + 'oauth2.test': JSON.stringify(token) + }); + + mocks.UrlFetchApp.resultFunction = () => JSON.stringify({ + access_token: Math.random().toString(36) + }); + + OAuth2.createService('test') + .setClientId('test') + .setTokenUrl('http://www.example.com') + .setPropertyStore(properties) + .generateCodeVerifier() + .refresh(); + + var storedToken = JSON.parse(properties.getProperty('oauth2.test')); + assert.equal(storedToken.refresh_token, 'bar'); + assert.equal(storedToken.refreshTokenExpiresAt, NOW_SECONDS + 360); + }); + it('should retain refresh expiry', () => { const NOW_SECONDS = OAuth2.getTimeInSeconds_(new Date()); const ONE_HOUR_AGO_SECONDS = NOW_SECONDS - 360;