Skip to content

Commit

Permalink
Merge pull request #212 from tigergraph/GML-1514-get-token-fix
Browse files Browse the repository at this point in the history
fix(getToken): fix getToken()
  • Loading branch information
parkererickson-tg authored Feb 15, 2024
2 parents ee05aa3 + 855713c commit 8dba301
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pyTigerGraph/pyTigerGraphAuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 `(<token>, <expiration_timestamp_unixtime>, <expiration_timestamp_ISO8601>)`.
If your TigerGraph instance is running version 3.5 or before, the return value is
a tuple of `(<token>, <expiration_timestamp_unixtime>, <expiration_timestamp_ISO8601>)`.
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.
Expand Down Expand Up @@ -231,7 +234,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.")


Expand Down

0 comments on commit 8dba301

Please sign in to comment.