Skip to content

Commit

Permalink
GML-1660 change authheader to token
Browse files Browse the repository at this point in the history
  • Loading branch information
Lu Zhou authored and Lu Zhou committed Jun 11, 2024
1 parent 5bc4f3e commit 089165b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pyTigerGraph/pyTigerGraphBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def _verify_jwt_token_support(self):
logger.debug("Attempting to verify JWT token support with getVer() on RestPP server.")
logger.debug(f"Using auth header: {self.authHeader}")
version = self.getVer()
# logger.info(f"Database version: {version}")
logger.info(f"Database version: {version}")

# Check JWT support for GSQL server
logger.debug(f"Attempting to get auth info with URL: {self.gsUrl + '/gsqlserver/gsql/simpleauth'}")
Expand Down Expand Up @@ -315,6 +315,7 @@ def _req(self, method: str, url: str, authMode: str = "token", headers: dict = N
_headers = {'Authorization': "Bearer " + self.jwtToken}
else:
_headers = {'Authorization': 'Basic {0}'.format(self.base64_credential)}

if headers:
_headers.update(headers)
if self.awsIamHeaders:
Expand Down
2 changes: 1 addition & 1 deletion tests/pyTigerGraphUnitTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ def make_connection(graphname: str = None):
jwtToken=server_config["jwtToken"]
)
if server_config.get("getToken", False):
conn.getToken(conn.createSecret(), setToken=True)
conn.getToken(conn.createSecret())

return conn
6 changes: 4 additions & 2 deletions tests/test_jwtAuth.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ def test_jwtauth(self):
# self.conn.gsql("CREATE GRAPH tests()")
# print (self.conn.graphname)
# self.conn.gsql("USE GRAPH mygraph")
# self.conn.getToken(self.conn.createSecret())
token = self.conn.getToken(self.conn.createSecret())

authheader = self.conn.authHeader
# print (token)

authheader = {'Authorization': "Bearer " + token[0]}
print (f"authheader from init conn: {authheader}")
dbversion = self.conn.getVer()
print (f"dbversion from init conn: {dbversion}")
Expand Down

0 comments on commit 089165b

Please sign in to comment.