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

Login weirdness #7

Open
kousu opened this issue Jun 16, 2020 · 0 comments
Open

Login weirdness #7

kousu opened this issue Jun 16, 2020 · 0 comments

Comments

@kousu
Copy link
Contributor

kousu commented Jun 16, 2020

We need to adjust the prepare() method to handle all the exceptional cases. In particular, there's a difference between an empty password, None for a password, and a wrong password -- even when accessing public datasets:

>>> list(osfclient.OSF(username='', password=None).project('fg8jy').storage().files)[0].name
'README.md'
>>> list(osfclient.OSF(username='', password='').project('fg8jy').storage().files)[0].name
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kousu/.local/lib/python3.6/site-packages/osfclient/api.py", line 24, in project
    return Project(self._json(self._get(url), 200), self.session)
  File "/home/kousu/.local/lib/python3.6/site-packages/osfclient/models/core.py", line 23, in _get
    return self.session.get(url, *args, **kwargs)
  File "/home/kousu/.local/lib/python3.6/site-packages/osfclient/models/session.py", line 45, in get
    raise UnauthorizedException()
osfclient.exceptions.UnauthorizedException
>>> list(osfclient.OSF(username='', password='afdsfs').project('fg8jy').storage().files)[0].name
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kousu/.local/lib/python3.6/site-packages/osfclient/api.py", line 24, in project
    return Project(self._json(self._get(url), 200), self.session)
  File "/home/kousu/.local/lib/python3.6/site-packages/osfclient/models/core.py", line 60, in _json
    status_code))
RuntimeError: Response has status code 502 not (200,)
>>> list(osfclient.OSF(username='sdfiljsdofj', password='afdsfs').project('fg8jy').storage().files)[0].name
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kousu/.local/lib/python3.6/site-packages/osfclient/api.py", line 24, in project
    return Project(self._json(self._get(url), 200), self.session)
  File "/home/kousu/.local/lib/python3.6/site-packages/osfclient/models/core.py", line 23, in _get
    return self.session.get(url, *args, **kwargs)
  File "/home/kousu/.local/lib/python3.6/site-packages/osfclient/models/session.py", line 45, in get
    raise UnauthorizedException()
osfclient.exceptions.UnauthorizedException
>>> list(osfclient.OSF(username='sdfiljsdofj', password='').project('fg8jy').storage().files)[0].name
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kousu/.local/lib/python3.6/site-packages/osfclient/api.py", line 24, in project
    return Project(self._json(self._get(url), 200), self.session)
  File "/home/kousu/.local/lib/python3.6/site-packages/osfclient/models/core.py", line 23, in _get
    return self.session.get(url, *args, **kwargs)
  File "/home/kousu/.local/lib/python3.6/site-packages/osfclient/models/session.py", line 45, in get
    raise UnauthorizedException()
osfclient.exceptions.UnauthorizedException
DorienHuijser added a commit that referenced this issue Jun 18, 2020
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

1 participant