def get_oauth_token_from_body(body):
 if six.PY3:
  body = body.decode('utf-8')
 credentials = urlparse.parse_qs(body)
 key = credentials['oauth_token'][0]
 secret = credentials['oauth_token_secret'][0]
 token = {'key': key, 'id': key, 'secret': secret}
 expires_at = credentials.get('oauth_expires_at')
 if expires_at:
  token['expires'] = expires_at[0]
 return token

def get_oauth_token_from_body ( body ) : if six . PY3 : body = body . decode ( 'utf-8' ) credentials = urlparse . parse_qs ( body ) key = credentials [ 'oauth_token' ] [ 0 ] secret = credentials [ 'oauth_token_secret' ] [ 0 ] token = { 'key' : key , 'id' : key , 'secret' : secret } expires_at = credentials . get ( 'oauth_expires_at' ) if expires_at : token [ 'expires' ] = expires_at [ 0 ] return token
parse the url response body to retrieve the oauth token key and secret .