Access Denied because of invalid token when using getVertexCount()

I’m confused why I get an access error even though I can use the same token to do other things.

I can drop a graph, create a graph, list a graph, getSchema() etc. But if I try conn.getVertexCount() I get an access denied error.

Access Denied because the input token = ‘[my token here]’ is invalid for graph ‘[my_graph_name here]’", ‘REST-10016’

I use pytigergraph to connect to a company Dev instance of TigerGraph

@ray Without seeing the code I’m not sure if I could pinpoint the issue… but I went ahead and created a notebook using that function. It’s using the latest version of pyTigerGraph. Can you run through the notebook to test it?

Feel free to make a copy of the notebook: Google Colab

Note: Some pyTigerGraph functions use the username & password. Other functions use tokens. The notebook below takes the UserID and Password and generates secrets and tokens.

Additional Information:

Hi @ray , can you also provide the version of pyTigerGraph and the database version you are using? Python traceback information and the code snippet on how you add the token to your connection would be helpful too. Additionally, this authentication error makes sense if your token is not valid, as getSchema() and create graph operations are handled through GSQL authentication, while getVertexCount() is handled with REST++ (token) authentication.

Thanks to both of you for the tips: I’ll read through the resources provided. It’s especially interesting to read of the two different auth types–makes more sense now. I mistakenly thought the other commands proved the token was good. This is an on-prem instance. getVersion also produces the error.

Lightly redacted trace is below

code:
tg_conn.getVertices(’[vertex here]’, limit=6)


TigerGraphException Traceback (most recent call last)
Cell In[12], line 1
----> 1 tg_conn.getVertices(’[vertex here]’, limit=6)

File , in pyTigerGraphVertex.getVertices(self, vertexType, select, where, limit, sort, fmt, withId, withType, timeout)
400 if timeout and timeout > 0:
401 url += ("?" if isFirst else “&”) + “timeout=” + str(timeout)
→ 403 ret = self._get(url)
405 if fmt == “json”:
406 ret = json.dumps(ret)

File ~–, in pyTigerGraphBase._get(self, url, authMode, headers, resKey, skipCheck, params, strictJson)
327 if logger.level == logging.DEBUG:
328 logger.debug("params: " + self._locals(locals()))
→ 330 res = self._req(“GET”, url, authMode, headers, None, resKey, skipCheck, params, strictJson)
332 if logger.level == logging.DEBUG:
333 logger.debug("return: " + str(res))

File —, in pyTigerGraphBase._req(self, method, url, authMode, headers, data, resKey, skipCheck, params, strictJson, jsonData)
288 raise TigerGraphException(res.text)
289 if not skipCheck:
→ 290 self._errorCheck(res)
291 if not resKey:
292 if logger.level == logging.DEBUG:

File —, in pyTigerGraphBase._errorCheck(self, res)
198 “”“Checks if the JSON document returned by an endpoint has contains error: true. If so,
199 it raises an exception.
200
(…)
206 TigerGraphException: if request returned with error, indicated in the returned JSON.
207 “””
208 if “error” in res and res[“error”] and res[“error”] != “false”:
209 # Endpoint might return string “false” rather than Boolean false
→ 210 raise TigerGraphException(res[“message”], (res[“code”] if “code” in res else None))

TigerGraphException: (“Access Denied because the input token = ‘’ is invalid for graph ‘’”, ‘REST-10016’)

Going into the admin panel as suggested and creating the new key solved this issue. I wasn’t using the right key. I was thrown off because some commands worked. Thanks again.

1 Like