-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathouth.py
30 lines (25 loc) · 845 Bytes
/
outh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
from flask import g #this can hold variables globally inside the whole app
from flask_oauthlib.client import OAuth
from dotenv import load_dotenv
load_dotenv()
oauth = OAuth()
client_id = os.getenv("CLIENT_ID")
client_secret = os.getenv("CILENT_SECRET")
#print(client_id,client_secret)
github = oauth.remote_app(
'github',
consumer_key= client_id,
consumer_secret = client_secret,
request_token_params = {"scope": "user:email"},
base_url="https://api.github.com/",
request_token_url=None,
access_token_method="POST",
access_token_url="https://github.com/login/oauth/access_token",
authorize_url= "https://github.com/login/oauth/authorize"
)
#pass the access token to the github user object
@github.tokengetter
def get_github_token():
if "access_token" in g:
return g.access_token