Skip to content

Commit 56f2ff9

Browse files
feat: add refresh_oauth_tokens() API (#92)
* refresh_oauth_token , include returned refresh_token The refresh_token can be used only once Users will need the new refresh_token, which is included in the API response, in order to call the refresh_oauth_token again if needed. * Update main.py * refresh_oauth_tokens , include returned json Token item The default `refresh_oauth_token` function returns only access_token. If user requires a new refresh_token too, they can use this new function that returns the complete refreshed Token that includes both the access_token and the new refresh_token * refresh_oauth_tokens , include returned json Token item * refresh_oauth_tokens, black formatter --------- Co-authored-by: simcha-gs <[email protected]>
1 parent 15ec5e6 commit 56f2ff9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/casdoor/main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,19 @@ def refresh_oauth_token(self, refresh_token: str, scope: str = "") -> str:
233233

234234
return access_token
235235

236+
def refresh_oauth_tokens(self, refresh_token: str, scope: str = "") -> Dict:
237+
"""
238+
Request the Casdoor server to get a refreshed Token.
239+
240+
:param refresh_token: refresh_token for send to Casdoor
241+
:param scope: OAuth scope
242+
:return: Response from Casdoor
243+
"""
244+
r = self.refresh_token_request(refresh_token, scope)
245+
refreshed_token = r.json()
246+
247+
return refreshed_token
248+
236249
def parse_jwt_token(self, token: str, **kwargs) -> Dict:
237250
"""
238251
Converts the returned access_token to real data using

0 commit comments

Comments
 (0)