Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit 5ce5fcf

Browse files
authored
Merge pull request #91 from IdentityPython/docs
[Documentation] How to Refresh token, example
2 parents 155ef33 + eee12cb commit 5ce5fcf

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

docs/source/contents/usage.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,41 @@ The identity representation with the information fetched from the user info endp
4949
We can even test the single logout
5050

5151

52+
Refresh token
53+
-------------
54+
55+
Here an example about how to refresh a token.
56+
It is important to consider that only scope=offline_access will get a usable refresh token.
57+
58+
59+
import requests
60+
61+
CLIENT_ID = "DBP60x3KUQfCYWZlqFaS_Q"
62+
CLIENT_SECRET="8526270403788522b2444e87ea90c53bcafb984119cec92eeccc12f1"
63+
REFRESH_TOKEN = "Z0FBQUFBQ ... lN2JNODYtZThjMnFsZUNDcg=="
64+
65+
data = {
66+
"grant_type" : "refresh_token",
67+
"client_id" : f"{CLIENT_ID}",
68+
"client_secret" : f"{CLIENT_SECRET}",
69+
"refresh_token" : f"{REFRESH_TOKEN}"
70+
}
71+
headers = {'Content-Type': "application/x-www-form-urlencoded" }
72+
response = requests.post(
73+
'https://127.0.0.1:8000/oidcop/token', verify=False, data=data, headers=headers
74+
)
75+
76+
oidc-op will return a json response like this::
77+
78+
{
79+
'access_token': 'eyJhbGc ... CIOH_09tT_YVa_gyTqg',
80+
'token_type': 'Bearer',
81+
'scope': 'openid profile email address phone offline_access',
82+
'refresh_token': 'Z0FBQ ... 1TE16cm1Tdg=='
83+
}
84+
85+
86+
5287
Introspection endpoint
5388
----------------------
5489

example/flask_op/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
"acr": "urn:oasis:names:tc:SAML:2.0:ac:classes:InternetProtocolPassword",
9292
"class": "oidcop.user_authn.user.UserPassJinja2",
9393
"kwargs": {
94-
"verify_endpoint": "verify/user",
94+
"verify_endpoint": "/verify/user",
9595
"template": "user_pass.jinja2",
9696
"db": {
9797
"class": "oidcop.util.JSONDictDB",

0 commit comments

Comments
 (0)