Skip to content

Instantly share code, notes, and snippets.

@umbum
Created January 19, 2019 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umbum/a5fe8939ef7c17a2359a05b78fd439a6 to your computer and use it in GitHub Desktop.
Save umbum/a5fe8939ef7c17a2359a05b78fd439a6 to your computer and use it in GitHub Desktop.
OAuth callback server
from flask import Flask, request
import requests
import json
app = Flask(__name__)
@app.route("/callback")
def callback():
code = request.args.get("code")
data = {
"client_id" : "deadbeef3b147d012f8b",
"client_secret" : "9eeeeeeeeee9999999aaaaaaaabbbbbffff11101",
"code" : code
}
headers = {
"accept" : "application/json"
}
r = requests.post("https://github.com/login/oauth/access_token", data=data, headers=headers)
res = r.json()
return res.get("access_token")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8182)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment