Created
January 17, 2019 11:31
-
-
Save iwconfig/bade5ea23c624c8bb0fc5e10df94892a to your computer and use it in GitHub Desktop.
simple callback server for oauth2. quits itself once code is retrieved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading, webbrowser | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
from urllib.parse import urlparse, parse_qs | |
class S(BaseHTTPRequestHandler): | |
def do_GET(self): | |
code = parse_qs(urlparse(self.path).query)['code'][0] | |
threading.Thread(target=httpd.shutdown, daemon=True).start() | |
def callback_server(server_class=HTTPServer, handler_class=S, port=8080): | |
global httpd | |
httpd = server_class((localhost, 5003), handler_class) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment