def parse_token_response(body, scope=None):
 try:
  params = json.loads(body)
 except ValueError:
  params = dict(urlparse.parse_qsl(body))
  for key in (u'expires_in', u'expires'):
   if (key in params):
    params[key] = int(params[key])
 if (u'scope' in params):
  params[u'scope'] = scope_to_list(params[u'scope'])
 if (u'expires' in params):
  params[u'expires_in'] = params.pop(u'expires')
 if (u'expires_in' in params):
  params[u'expires_at'] = (time.time() + int(params[u'expires_in']))
 params = OAuth2Token(params, old_scope=scope)
 validate_token_parameters(params)
 return params

def parse_token_response ( body , scope = None ) : try : params = json . loads ( body ) except ValueError : params = dict ( urlparse . parse_qsl ( body ) ) for key in ( u'expires_in' , u'expires' ) : if ( key in params ) : params [ key ] = int ( params [ key ] ) if ( u'scope' in params ) : params [ u'scope' ] = scope_to_list ( params [ u'scope' ] ) if ( u'expires' in params ) : params [ u'expires_in' ] = params . pop ( u'expires' ) if ( u'expires_in' in params ) : params [ u'expires_at' ] = ( time . time ( ) + int ( params [ u'expires_in' ] ) ) params = OAuth2Token ( params , old_scope = scope ) validate_token_parameters ( params ) return params
parse the json token response body into a dict .