Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dist/OAuth2.gs
Original file line number Diff line number Diff line change
Expand Up @@ -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_
});

Expand Down
1 change: 0 additions & 1 deletion src/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_
});

Expand Down
29 changes: 29 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down