Skip to content Skip to sidebar Skip to footer

Server For Testing Oauth2 Callback

I need to run an HTTP Server in Python to handle a callback from a website which uses OAuth2. I did some search and found that SimpleHTTPServer or BaseHTTPServer is what I was look

Solution 1:

The simplest working example I found is in this project:

https://github.com/demianbrecht/sanction

In particular: example/server.py

If you are using BaseHTTPRequestHandler and that is the only thing your server is handling your class might be as simple as:

from urlparse import urlparse,parse_qsl
classHandler(BaseHTTPRequestHandler):

    defdo_GET(self):
        url = urlparse(self.path)
        code = parse_qsl(url.query)['code']
        ...

Post a Comment for "Server For Testing Oauth2 Callback"