import requests from http.server import * import webbrowser from oauthlib.oauth2 import WebApplicationClient class SavingRequestHandler(SimpleHTTPRequestHandler): def do_GET(self): print(self.path) def do_POST(self): content_length = int(self.headers.get('Content-Length')) print(self.rfile.read(content_length)) def wait_for_request(server_class=HTTPServer, handler_class=SavingHTTPRequestHandler): server_address = ('', 5635) httpd = server_class(server_address, handler_class) return httpd.handle_request() def authenticate(): CLIENT_ID = "a79bae348867427690ca6df9903e4af0" AUTH_URL = "https://oauth.battle.net/authorize" client = WebApplicationClient(CLIENT_ID) url = client.prepare_request_uri( AUTH_URL, redirect_uri = 'http://localhost:5635/login_success', scope = ['openid'], state = 'AbCdEfG' ) webbrowser.open(url) wait_for_request() authenticate()