From e8780f9695c18b9f0f7748f4b3991fd005680ceb Mon Sep 17 00:00:00 2001 From: Parker Erickson Date: Tue, 13 Feb 2024 15:33:14 -0600 Subject: [PATCH 1/2] fix(getToken): fix getToken() --- pyTigerGraph/pyTigerGraphAuth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyTigerGraph/pyTigerGraphAuth.py b/pyTigerGraph/pyTigerGraphAuth.py index 4476db60..8577cd80 100644 --- a/pyTigerGraph/pyTigerGraphAuth.py +++ b/pyTigerGraph/pyTigerGraphAuth.py @@ -231,7 +231,7 @@ def getToken(self, secret: str = None, setToken: bool = True, lifetime: int = No elif not(success) and not(secret): res = self._post(self.restppUrl+"/requesttoken", authMode="pwd", data=str({"graph": self.graphname}), resKey="results") success = True - else: + elif not(success) and (int(s) < 3 or (int(s) == 3 and int(m) < 5)): raise TigerGraphException("Cannot request a token with username/password for versions < 3.5.") From 855713c71cb6668b00ef0c1329df5a74f9699de6 Mon Sep 17 00:00:00 2001 From: Parker Erickson Date: Tue, 13 Feb 2024 21:17:33 -0600 Subject: [PATCH 2/2] fix(doc): update return types --- pyTigerGraph/pyTigerGraphAuth.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyTigerGraph/pyTigerGraphAuth.py b/pyTigerGraph/pyTigerGraphAuth.py index 8577cd80..fa5e775a 100644 --- a/pyTigerGraph/pyTigerGraphAuth.py +++ b/pyTigerGraph/pyTigerGraphAuth.py @@ -177,7 +177,7 @@ def dropSecret(self, alias: Union[str, list], ignoreErrors: bool = True) -> str: return res - def getToken(self, secret: str = None, setToken: bool = True, lifetime: int = None) -> tuple: + def getToken(self, secret: str = None, setToken: bool = True, lifetime: int = None) -> Union[tuple, str]: """Requests an authorization token. This function returns a token only if REST++ authentication is enabled. If not, an exception @@ -194,9 +194,12 @@ def getToken(self, secret: str = None, setToken: bool = True, lifetime: int = No Duration of token validity (in seconds, default 30 days = 2,592,000 seconds). Returns: - A tuple of `(, , )`. + If your TigerGraph instance is running version 3.5 or before, the return value is + a tuple of `(, , )`. The return value can be ignored, as the token is automatically set for the connection after this call. + If your TigerGraph instance is running version 3.6 or later, the return value is just the token. + [NOTE] The expiration timestamp's time zone might be different from your computer's local time zone.