def create_callback_server(session):
 class CallbackHandler(SimpleHTTPServer.SimpleHTTPRequestHandler, ):
  def do_GET(self):
   params = cgi.parse_qs(self.path.split('?', 1)[1], keep_blank_values=False)
   session.REQUEST_TOKEN = OAuthToken(params['oauth_token'][0], params['oauth_token_secret'][0])
   session.REQUEST_TOKEN.set_verifier(params['oauth_verifier'][0])
   self.send_response(200)
   self.send_header('Content-Type', 'text/plain')
   self.end_headers()
   self.wfile.write('OAuth request token fetched; you can close this window.')
  def log_request(self, code='-', size='-'):
   pass
 server = SocketServer.TCPServer(('127.0.0.1', 0), CallbackHandler)
 return server

def create_callback_server ( session ) : class CallbackHandler ( SimpleHTTPServer . SimpleHTTPRequestHandler , ) : def do_GET ( self ) : params = cgi . parse_qs ( self . path . split ( '?' , 1 ) [ 1 ] , keep_blank_values = False ) session . REQUEST_TOKEN = OAuthToken ( params [ 'oauth_token' ] [ 0 ] , params [ 'oauth_token_secret' ] [ 0 ] ) session . REQUEST_TOKEN . set_verifier ( params [ 'oauth_verifier' ] [ 0 ] ) self . send_response ( 200 ) self . send_header ( 'Content-Type' , 'text/plain' ) self . end_headers ( ) self . wfile . write ( 'OAuth request token fetched; you can close this window.' ) def log_request ( self , code = '-' , size = '-' ) : pass server = SocketServer . TCPServer ( ( '127.0.0.1' , 0 ) , CallbackHandler ) return server
adapted from URL simple server to handle callbacks from oauth request to browser .