@@ -329,6 +329,10 @@ def get(self, service=None):
329
329
# v2 tokens are just the provider name and the refresh token
330
330
# and they have no stored state on the server
331
331
if statetoken .version == 2 :
332
+
333
+ if service .has_key ('refresh-token-rotation' ) and service ['refresh-token-rotation' ]:
334
+ raise Exception ('Error: This service uses refresh token rotation which is not compatible with AuthID v2' )
335
+
332
336
authid = 'v2:' + statetoken .service + ':' + resp ['refresh_token' ]
333
337
dbmodel .update_fetch_token (statetoken .fetchtoken , authid )
334
338
@@ -427,7 +431,7 @@ def post(self):
427
431
resp = json .loads (content )
428
432
except :
429
433
error = 'Error: Invalid CLI token'
430
- raise
434
+ raise Exception ( error )
431
435
432
436
urlfetch .set_default_fetch_deadline (20 )
433
437
url = service ['auth-url' ]
@@ -454,6 +458,11 @@ def post(self):
454
458
# v2 tokens are just the provider name and the refresh token
455
459
# and they have no stored state on the server
456
460
if tokenversion == 2 :
461
+
462
+ if service .has_key ('refresh-token-rotation' ) and service ['refresh-token-rotation' ]:
463
+ error = 'Error: This service uses refresh token rotation which is not compatible with AuthID v2'
464
+ raise Exception (error )
465
+
457
466
authid = 'v2:' + id + ':' + resp ['refresh_token' ]
458
467
fetchtoken = dbmodel .create_fetch_token (resp )
459
468
dbmodel .update_fetch_token (fetchtoken , authid )
@@ -742,9 +751,13 @@ def process(self, authid):
742
751
logging .info ('Caching response to: %s for %s secs, service: %s' , keyid , exp_secs - 10 , servicetype )
743
752
744
753
# Write the result back to the client
745
- self .response .write (json .dumps (
746
- {'access_token' : resp ['access_token' ], 'expires' : exp_secs , 'type' : servicetype ,
747
- 'v2_authid' : 'v2:' + entry .service + ':' + rt }))
754
+ if service .has_key ('refresh-token-rotation' ) and service ['refresh-token-rotation' ]:
755
+ self .response .write (json .dumps (
756
+ {'access_token' : resp ['access_token' ], 'expires' : exp_secs , 'type' : servicetype }))
757
+ else :
758
+ self .response .write (json .dumps (
759
+ {'access_token' : resp ['access_token' ], 'expires' : exp_secs , 'type' : servicetype ,
760
+ 'v2_authid' : 'v2:' + entry .service + ':' + rt }))
748
761
749
762
except :
750
763
logging .exception ('handler error for ' + servicetype )
0 commit comments