(pyvo2) jrobinson@mp131325:rsp_pyvo_test $ conda list # packages in environment at /Users/jrobinson/miniconda3/envs/pyvo2: # # Name Version Build Channel astropy 6.0.1 pypi_0 pypi astropy-iers-data 0.2024.5.27.0.30.8 pypi_0 pypi bzip2 1.0.8 h93a5062_5 conda-forge ca-certificates 2024.2.2 hf0a4a13_0 conda-forge certifi 2024.2.2 pypi_0 pypi charset-normalizer 3.3.2 pypi_0 pypi idna 3.7 pypi_0 pypi libffi 3.4.2 h3422bc3_5 conda-forge libsqlite 3.45.3 h091b4b1_0 conda-forge libzlib 1.2.13 hfb2fe0b_6 conda-forge ncurses 6.5 hb89a1cb_0 conda-forge numpy 1.26.4 pypi_0 pypi openssl 3.3.0 hfb2fe0b_3 conda-forge packaging 24.0 pypi_0 pypi pip 24.0 pyhd8ed1ab_0 conda-forge pyerfa 2.0.1.4 pypi_0 pypi python 3.9.19 hd7ebdb9_0_cpython conda-forge pyvo 1.5.2 pypi_0 pypi pyyaml 6.0.1 pypi_0 pypi readline 8.2 h92ec313_1 conda-forge requests 2.32.3 pypi_0 pypi setuptools 70.0.0 pyhd8ed1ab_0 conda-forge tk 8.6.13 h5083fa2_1 conda-forge tzdata 2024a h0c530f3_0 conda-forge urllib3 2.2.1 pypi_0 pypi wheel 0.43.0 pyhd8ed1ab_1 conda-forge xz 5.2.6 h57fd34a_0 conda-forge (pyvo2) jrobinson@mp131325:rsp_pyvo_test $ cat rsp_stelios.py import requests import pyvo #service_name = "data-dev" #tap_url = "https://data-dev.lsst.cloud/api/ssotap" tap_url = "https://data.lsst.cloud/api/ssotap" #token = 'token_here' token = 'XXX' # Setup authorization s = requests.Session() s.headers["Authorization"] = "Bearer " + token auth = pyvo.auth.authsession.AuthSession() auth.credentials.set("lsst-token", s) auth.add_security_method_for_url(tap_url, "lsst-token") auth.add_security_method_for_url(tap_url + "/sync", "lsst-token") auth.add_security_method_for_url(tap_url + "/async", "lsst-token") auth.add_security_method_for_url(tap_url + "/tables", "lsst-token") # Query tap_service = pyvo.dal.TAPService(tap_url, session=auth) jobres = tap_service.run_async("SELECT TOP 10 * FROM TAP_SCHEMA.schemas") print(jobres) s.close() (pyvo2) jrobinson@mp131325:rsp_pyvo_test $ python rsp_stelios.py Traceback (most recent call last): File "/Users/jrobinson/miniconda3/envs/pyvo2/lib/python3.9/site-packages/pyvo/dal/tap.py", line 687, in _update response.raise_for_status() File "/Users/jrobinson/miniconda3/envs/pyvo2/lib/python3.9/site-packages/requests/models.py", line 1024, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://data.lsst.cloud/api/ssotap/async During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/jrobinson/rsp_pyvo_test/rsp_stelios.py", line 22, in jobres = tap_service.run_async("SELECT TOP 10 * FROM TAP_SCHEMA.schemas") File "/Users/jrobinson/miniconda3/envs/pyvo2/lib/python3.9/site-packages/pyvo/dal/tap.py", line 320, in run_async job = AsyncTAPJob.create( File "/Users/jrobinson/miniconda3/envs/pyvo2/lib/python3.9/site-packages/pyvo/dal/tap.py", line 643, in create job = cls(response.url, session=session) File "/Users/jrobinson/miniconda3/envs/pyvo2/lib/python3.9/site-packages/pyvo/dal/tap.py", line 657, in __init__ self._update() File "/Users/jrobinson/miniconda3/envs/pyvo2/lib/python3.9/site-packages/pyvo/dal/tap.py", line 689, in _update raise DALServiceError.from_except(ex, self.url) pyvo.dal.exceptions.DALServiceError: 401 Client Error: Unauthorized for url: https://data.lsst.cloud/api/ssotap/async (pyvo2) jrobinson@mp131325:rsp_pyvo_test $ cat rsp_stelios2.py import pyvo import os # RSP_TAP_SERVICE = 'https://data-dev.lsst.cloud/api/tap' RSP_TAP_SERVICE = 'https://data.lsst.cloud/api/tap' homedir = os.path.expanduser('~') token_file = os.path.join(homedir,'.rsp-tap.token') with open(token_file, 'r') as f: token_str = f.readline() # token_str = "test" token = 'XXX' cred = pyvo.auth.CredentialStore() cred.set_password("x-oauth-basic", token_str) credential = cred.get("ivo://ivoa.net/sso#BasicAA") rsp_tap = pyvo.dal.TAPService(RSP_TAP_SERVICE, credential) print(rsp_tap.tables) (pyvo2) jrobinson@mp131325:rsp_pyvo_test $ python rsp_stelios2.py (pyvo2) jrobinson@mp131325:rsp_pyvo_test $ cat rsp_stelios3.py import pyvo import os # RSP_TAP_SERVICE = 'https://data-dev.lsst.cloud/api/tap' RSP_TAP_SERVICE = 'https://data.lsst.cloud/api/tap' homedir = os.path.expanduser('~') token_file = os.path.join(homedir,'.rsp-tap.token') with open(token_file, 'r') as f: token_str = f.readline() cred = pyvo.auth.CredentialStore() cred.set_password("x-oauth-basic", token_str) credential = cred.get("ivo://ivoa.net/sso#BasicAA") print(credential.auth) print(credential.headers) (pyvo2) jrobinson@mp131325:rsp_pyvo_test $ python rsp_stelios3.py ('x-oauth-basic', 'XXX\n') {'User-Agent': 'pyVO/1.5.2 Python/3.9.19 (Darwin)', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'} (pyvo2) jrobinson@mp131325:rsp_pyvo_test $