Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(getToken): fix getToken() #212

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)):
parkererickson-tg marked this conversation as resolved.
Show resolved Hide resolved
raise TigerGraphException("Cannot request a token with username/password for versions < 3.5.")


Expand Down