def recreate_token_data(context, token_data=None, expires=None, user_ref=None, project_ref=None):
 new_expires = expires
 project_id = None
 user_id = None
 domain_id = None
 methods = ['password', 'token']
 extras = {}
 if token_data:
  token = token_data['token']
  domain_id = (token['domain']['id'] if ('domain' in token) else None)
  project_id = (token['project']['id'] if ('project' in token) else None)
  if (not new_expires):
   new_expires = token.get('expires_at', token.get('expires'))
  user_id = token['user']['id']
  methods = token['methods']
  extras = token['extras']
 else:
  token = None
  project_id = (project_ref['id'] if project_ref else None)
  user_id = user_ref['id']
 token_data_helper = TokenDataHelper(context)
 return token_data_helper.get_token_data(user_id, methods, extras, domain_id, project_id, new_expires, token=token)

def recreate_token_data ( context , token_data = None , expires = None , user_ref = None , project_ref = None ) : new_expires = expires project_id = None user_id = None domain_id = None methods = [ 'password' , 'token' ] extras = { } if token_data : token = token_data [ 'token' ] domain_id = ( token [ 'domain' ] [ 'id' ] if ( 'domain' in token ) else None ) project_id = ( token [ 'project' ] [ 'id' ] if ( 'project' in token ) else None ) if ( not new_expires ) : new_expires = token . get ( 'expires_at' , token . get ( 'expires' ) ) user_id = token [ 'user' ] [ 'id' ] methods = token [ 'methods' ] extras = token [ 'extras' ] else : token = None project_id = ( project_ref [ 'id' ] if project_ref else None ) user_id = user_ref [ 'id' ] token_data_helper = TokenDataHelper ( context ) return token_data_helper . get_token_data ( user_id , methods , extras , domain_id , project_id , new_expires , token = token )
recreate token from an existing token .