Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using hsclient.HydroShare requires user have account #26

Open
aaraney opened this issue Sep 22, 2021 · 1 comment
Open

Using hsclient.HydroShare requires user have account #26

aaraney opened this issue Sep 22, 2021 · 1 comment

Comments

@aaraney
Copy link
Member

aaraney commented Sep 22, 2021

A user must have a HydroShare account and login to use hsclient.HydroShare, as a user I would like the choice to browse anonymously. I am not sure the implications this has on using https://hydroshare.org/hsapi, however public resources are still discoverable and queryable via the browser without logging in. This may be an edge case that is undesirable, but I think it is worth documenting in an issue.

I believe this stems from HydroShareSession's login logic. Currently, the requests session object is given username=None, password=None by default.

from hsclient import HydroShare

session = HydroShare()
res = session.resource("51188b5303514b20b1b092a24c6620e9")

>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/github/hydroshare_jupyter_sync/venv/lib/python3.8/site-packages/hsclient/hydroshare.py", line 910, in resource
    res.metadata
  File "~/github/hydroshare_jupyter_sync/venv/lib/python3.8/site-packages/hsclient/hydroshare.py", line 188, in metadata
    return self._metadata
  File "~/github/hydroshare_jupyter_sync/venv/lib/python3.8/site-packages/hsclient/hydroshare.py", line 95, in _metadata
    self._retrieved_metadata = self._retrieve_and_parse(self.metadata_path)
  File "~/github/hydroshare_jupyter_sync/venv/lib/python3.8/site-packages/hsclient/hydroshare.py", line 193, in metadata_path
    return urlparse(str(self._map.describes.is_documented_by)).path
  File "~/github/hydroshare_jupyter_sync/venv/lib/python3.8/site-packages/hsclient/hydroshare.py", line 89, in _map
    self._retrieved_map = self._retrieve_and_parse(self._map_path)
  File "~/github/hydroshare_jupyter_sync/venv/lib/python3.8/site-packages/hsclient/hydroshare.py", line 151, in _retrieve_and_parse
    file_str = self._hs_session.retrieve_string(path)
  File "~/github/hydroshare_jupyter_sync/venv/lib/python3.8/site-packages/hsclient/hydroshare.py", line 673, in retrieve_string
    file = self.get(path, status_code=200, allow_redirects=True)
  File "~/github/hydroshare_jupyter_sync/venv/lib/python3.8/site-packages/hsclient/hydroshare.py", line 737, in get
    raise Exception(
Exception: Failed GET https://www.hydroshare.org:443/resource/51188b5303514b20b1b092a24c6620e9/data/resourcemap.xml/, status_code 401, message b'{"detail":"Invalid username/password."}'
@huard
Copy link

huard commented May 30, 2023

This would be useful for our test suite and documentation where we don't want to expose auth information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants