Skip to content

Commit

Permalink
Merge pull request #263 from tigergraph/GML-1893-async-auth-fix
Browse files Browse the repository at this point in the history
fix ordering of auth
  • Loading branch information
parkererickson-tg authored Oct 31, 2024
2 parents dfc312d + 903a9f3 commit 1514d4c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions pyTigerGraph/pyTigerGraphAuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,18 +166,24 @@ def _token(self, secret: str = None, lifetime: int = None, token: str = None, _m
if _method:
method = _method

# Try using TG 4.1 endpoint first, if url not found then try <4.1 endpoint
# Try using TG 3.x endpoint first, if url not found then try <4.1 endpoint
try:
res = self._req(method, url, authMode=authMode,
data=data, resKey=None, jsonData=True)
mainVer = 4
res = self._req(
method, alt_url, authMode=authMode, data=alt_data, resKey=None)
mainVer = 3
except:
try:
res = self._req(
method, alt_url, authMode=authMode, data=alt_data, resKey=None)
mainVer = 3
except Exception as e:
raise TigerGraphException("Error requesting token. Check if the connection's graphname is correct.", 400)
res = self._req(method, url, authMode=authMode,
data=data, resKey=None, jsonData=True)
mainVer = 4
except requests.exceptions.HTTPError as e:
if e.response.status_code == 404:
raise TigerGraphException(
"Error requesting token. Check if the connection's graphname is correct and that REST authentication is enabled.",
404
)
else:
raise e

# uses mainVer instead of _versionGreaterThan4_0 since you need a token for verson checking
return res, mainVer
Expand Down

0 comments on commit 1514d4c

Please sign in to comment.