Skip to content

Commit

Permalink
Merge pull request #91 from fabric-testbed/token-refresh
Browse files Browse the repository at this point in the history
Refresh token when needed and expose API to determine project name
  • Loading branch information
kthare10 authored Nov 5, 2024
2 parents a1b6515 + 27cffcd commit 2d144cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fabrictestbed/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "1.7.8"
__version__ = "1.7.9"
__VERSION__ = __version__
14 changes: 14 additions & 0 deletions fabrictestbed/token_manager/token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,17 @@ def get_user_email(self) -> str:
if not self.user_email and self.get_id_token() and self.cm_proxy:
self._extract_project_and_user_info_from_token(cm_host=self.cm_proxy.host)
return self.user_email

def get_project_name(self) -> str:
"""
Retrieve the project name associated with the current session.
This method returns the project name if it has already been determined. If the project name
has not been set and an identity token is available, it will attempt to extract
the project name by decoding the token using the credential manager proxy.
@return: The project_name if available; otherwise, None.
"""
if not self.project_name and self.get_id_token() and self.cm_proxy:
self._extract_project_and_user_info_from_token(cm_host=self.cm_proxy.host)
return self.project_name

0 comments on commit 2d144cd

Please sign in to comment.