Skip to content

Commit

Permalink
feat: add refresh_oauth_tokens() API (#92)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
simchaSure and simcha-gs authored Feb 20, 2025
1 parent 15ec5e6 commit 56f2ff9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/casdoor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ def refresh_oauth_token(self, refresh_token: str, scope: str = "") -> str:

return access_token

def refresh_oauth_tokens(self, refresh_token: str, scope: str = "") -> Dict:
"""
Request the Casdoor server to get a refreshed Token.
:param refresh_token: refresh_token for send to Casdoor
:param scope: OAuth scope
:return: Response from Casdoor
"""
r = self.refresh_token_request(refresh_token, scope)
refreshed_token = r.json()

return refreshed_token

def parse_jwt_token(self, token: str, **kwargs) -> Dict:
"""
Converts the returned access_token to real data using
Expand Down

0 comments on commit 56f2ff9

Please sign in to comment.