@@ -329,6 +329,10 @@ def get(self, service=None):
329329 # v2 tokens are just the provider name and the refresh token
330330 # and they have no stored state on the server
331331 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+
332336 authid = 'v2:' + statetoken .service + ':' + resp ['refresh_token' ]
333337 dbmodel .update_fetch_token (statetoken .fetchtoken , authid )
334338
@@ -427,7 +431,7 @@ def post(self):
427431 resp = json .loads (content )
428432 except :
429433 error = 'Error: Invalid CLI token'
430- raise
434+ raise Exception ( error )
431435
432436 urlfetch .set_default_fetch_deadline (20 )
433437 url = service ['auth-url' ]
@@ -454,6 +458,11 @@ def post(self):
454458 # v2 tokens are just the provider name and the refresh token
455459 # and they have no stored state on the server
456460 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+
457466 authid = 'v2:' + id + ':' + resp ['refresh_token' ]
458467 fetchtoken = dbmodel .create_fetch_token (resp )
459468 dbmodel .update_fetch_token (fetchtoken , authid )
@@ -742,9 +751,13 @@ def process(self, authid):
742751 logging .info ('Caching response to: %s for %s secs, service: %s' , keyid , exp_secs - 10 , servicetype )
743752
744753 # 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 }))
748761
749762 except :
750763 logging .exception ('handler error for ' + servicetype )
0 commit comments