Dear Caterina,
many thanks - we’ve recently upgraded to pyBIS 1.36.3, openBIS 20.10.7.1.
I tried to come back to PAT, but I’m stuck (again or still…)
Could you kindly take another look?
When I log in with a session_token, I can create the PAT:
pat_name = 'PAT_20231024_T01'
pat = oBis.get_or_create_personal_access_token(sessionName=pat_name)
oBis.set_token(pat, save_token=True)
It also gets created:
attribute value
---------------- ------------------------------------------------------------------
permId $pat-ulrichkerzel-2...
sessionName PAT_20231024_T01
validFromDate 2023-10-24 09:26:17
validToDate 2023-11-23 08:26:17
accessDate 2023-10-25 07:44:16
owner ulrichkerzel
registrator ulrichkerzel
registrationDate 2023-10-24 09:26:46
modifier ulrichkerzel
modificationDate 2023-10-24 09:26:46
which is the same information as in personal-access-tokens.json
.
But then when I try to use it:
oBis = Openbis(server_url, verify_certificates=False)
pat = oBis.get_or_create_personal_access_token(sessionName='PAT_20231024_T01')
I get the following exception:
{"method": "createPersonalAccessTokens", "params": ["$pat-ulrichkerzel-2<removed for security>", {"@type": "as.dto.pat.create.PersonalAccessTokenCreation", "sessionName": "PAT_20231024_T01", "validFromDate": 1698213754425, "validToDate": 1703402107466}], "id": "2", "jsonrpc": "2.0"}
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File ~/.cache/pypoetry/virtualenvs/openbis-qARisZC2-py3.10/lib/python3.10/site-packages/pybis/pybis.py:2043, in Openbis.get_or_create_personal_access_token(self, sessionName, validFrom, validTo, force)
2042 try:
-> 2043 resp = self._post_request(self.as_v3, request)
2044 except ValueError as exc:
File ~/.cache/pypoetry/virtualenvs/openbis-qARisZC2-py3.10/lib/python3.10/site-packages/pybis/pybis.py:1249, in Openbis._post_request(self, resource, request)
1246 """internal method, used to handle all post requests and serializing / deserializing
1247 data
1248 """
-> 1249 return self._post_request_full_url(urljoin(self.url, resource), request)
File ~/.cache/pypoetry/virtualenvs/openbis-qARisZC2-py3.10/lib/python3.10/site-packages/pybis/pybis.py:1296, in Openbis._post_request_full_url(self, full_url, request)
1295 print(json.dumps(request))
-> 1296 raise ValueError(resp["error"]["message"])
1297 elif "result" in resp:
ValueError: Personal access tokens cannot be used to manage personal access tokens.
During handling of the above exception, another exception occurred:
NotImplementedError Traceback (most recent call last)
/home/kerzel/Repositories/openbis/openbis/test_pat.ipynb Cell 3 line 5
1 ##
...
2047 )
2048 try:
2049 return self.get_personal_access_token(resp[0]["permId"])
NotImplementedError: Your openBIS instance does not support personal access tokens. Please upgrade your server and activate them.
Admittedly, I’m a bit confused.
When I log in via the session ID, there is a PAT (also in the json),
the first part of the output (with the method
) also seems to return the PAT as it’s in the params
- but there is still an exception?
Any help would be greatly appreciated,
many thanks
Ulrich