File tree 2 files changed +9
-4
lines changed
2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -50,3 +50,9 @@ Copy the code value, use `curl` to get the access token:
50
50
```
51
51
curl -u "${CLIENT_ID}:${CLIENT_SECRET}" -XPOST http://127.0.0.1:5000/oauth/token -F grant_type=authorization_code -F code=RSv6j745Ri0DhBSvi2RQu5JKpIVvLm8SFd5ObjOZZSijohe0
52
52
```
53
+
54
+ Now you can access the userinfo endpoint:
55
+
56
+ ``` bash
57
+ $ curl -H " Authorization: Bearer ${access_token} " http://127.0.0.1:5000/oauth/userinfo
58
+ ```
Original file line number Diff line number Diff line change 5
5
from authlib .integrations .flask_oauth2 import current_token
6
6
from authlib .oauth2 import OAuth2Error
7
7
from .models import db , User , OAuth2Client
8
- from .oauth2 import authorization , require_oauth
8
+ from .oauth2 import authorization , require_oauth , generate_user_info
9
9
10
10
11
11
bp = Blueprint (__name__ , 'home' )
@@ -97,8 +97,7 @@ def issue_token():
97
97
return authorization .create_token_response ()
98
98
99
99
100
- @bp .route ('/api/me ' )
100
+ @bp .route ('/oauth/userinfo ' )
101
101
@require_oauth ('profile' )
102
102
def api_me ():
103
- user = current_token .user
104
- return jsonify (id = user .id , username = user .username )
103
+ return jsonify (generate_user_info (current_token .user , current_token .scope ))
You can’t perform that action at this time.
0 commit comments