Skip to content

Commit d048d64

Browse files
authored
Authlib will handle access token automatically
1 parent 69d8eaa commit d048d64

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

01-Login/server.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from flask import url_for
1515
from authlib.flask.client import OAuth
1616
from six.moves.urllib.parse import urlencode
17-
import requests
1817

1918
import constants
2019

@@ -76,21 +75,16 @@ def home():
7675

7776
@app.route('/callback')
7877
def callback_handling():
79-
resp = auth0.authorize_access_token()
80-
81-
url = AUTH0_BASE_URL + '/userinfo'
82-
headers = {'authorization': 'Bearer ' + resp['access_token']}
83-
resp = requests.get(url, headers=headers)
78+
auth0.authorize_access_token()
79+
resp = auth0.get('userinfo')
8480
userinfo = resp.json()
8581

8682
session[constants.JWT_PAYLOAD] = userinfo
87-
8883
session[constants.PROFILE_KEY] = {
8984
'user_id': userinfo['sub'],
9085
'name': userinfo['name'],
9186
'picture': userinfo['picture']
9287
}
93-
9488
return redirect('/dashboard')
9589

9690

0 commit comments

Comments
 (0)