File tree 3 files changed +29
-2
lines changed
3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -759,7 +759,6 @@ Service_.prototype.ensureExpiresAtSet_ = function(token) {
759
759
Service_ . prototype . refresh = function ( ) {
760
760
validate_ ( {
761
761
'Client ID' : this . clientId_ ,
762
- 'Client Secret' : this . clientSecret_ ,
763
762
'Token URL' : this . tokenUrl_
764
763
} ) ;
765
764
Original file line number Diff line number Diff line change @@ -666,7 +666,6 @@ Service_.prototype.ensureExpiresAtSet_ = function(token) {
666
666
Service_ . prototype . refresh = function ( ) {
667
667
validate_ ( {
668
668
'Client ID' : this . clientId_ ,
669
- 'Client Secret' : this . clientSecret_ ,
670
669
'Token URL' : this . tokenUrl_
671
670
} ) ;
672
671
Original file line number Diff line number Diff line change @@ -387,6 +387,35 @@ describe('Service', () => {
387
387
done ( ) ;
388
388
} ) ;
389
389
390
+ it ( 'should refresh token granted for PKCE' , ( ) => {
391
+ const NOW_SECONDS = OAuth2 . getTimeInSeconds_ ( new Date ( ) ) ;
392
+ const ONE_HOUR_AGO_SECONDS = NOW_SECONDS - 360 ;
393
+ var token = {
394
+ granted_time : ONE_HOUR_AGO_SECONDS ,
395
+ expires_in : 100 ,
396
+ refresh_token : 'bar' ,
397
+ refresh_token_expires_in : 720
398
+ } ;
399
+ var properties = new MockProperties ( {
400
+ 'oauth2.test' : JSON . stringify ( token )
401
+ } ) ;
402
+
403
+ mocks . UrlFetchApp . resultFunction = ( ) => JSON . stringify ( {
404
+ access_token : Math . random ( ) . toString ( 36 )
405
+ } ) ;
406
+
407
+ OAuth2 . createService ( 'test' )
408
+ . setClientId ( 'test' )
409
+ . setTokenUrl ( 'http://www.example.com' )
410
+ . setPropertyStore ( properties )
411
+ . generateCodeVerifier ( )
412
+ . refresh ( ) ;
413
+
414
+ var storedToken = JSON . parse ( properties . getProperty ( 'oauth2.test' ) ) ;
415
+ assert . equal ( storedToken . refresh_token , 'bar' ) ;
416
+ assert . equal ( storedToken . refreshTokenExpiresAt , NOW_SECONDS + 360 ) ;
417
+ } ) ;
418
+
390
419
it ( 'should retain refresh expiry' , ( ) => {
391
420
const NOW_SECONDS = OAuth2 . getTimeInSeconds_ ( new Date ( ) ) ;
392
421
const ONE_HOUR_AGO_SECONDS = NOW_SECONDS - 360 ;
You can’t perform that action at this time.
0 commit comments