Closed Vidminas closed 11 months ago
thank you @Vidminas for flagging this issue. Looks like it is related to #36 . httpx
library version bump seems to be the cause. Any thoughts @hrchu ?
@Vidminas nice catch, would you like to send a PR for this?
The issue fixed in #39. @Vidminas whould you like to have a try?
A simple login snippet is problematic:
running this raises
HTTPStatusError: Redirect response '302 Found' for url 'https://solidcommunity.net/login/password'
.Full stack trace
HTTPStatusError Traceback (most recent call last) Cell In[1], line 11 9 auth = Auth() 10 api = SolidAPI(auth) ---> 11 auth.login(IDP, USERNAME, PASSWORD) File [c:\Users\Vidminas\.conda\envs\solid\Lib\site-packages\solid\auth.py:25](file:///C:/Users/Vidminas/.conda/envs/solid/Lib/site-packages/solid/auth.py:25), in Auth.login(self, idp, username, password) 23 r = self.client.post(url, data=data) 24 # print(r) ---> 25 r.raise_for_status() 27 if not self.is_login: 28 raise Exception('Cannot login.') File [c:\Users\Vidminas\.conda\envs\solid\Lib\site-packages\httpx\_models.py:736](file:///C:/Users/Vidminas/.conda/envs/solid/Lib/site-packages/httpx/_models.py:736), in Response.raise_for_status(self) 734 error_type = error_types.get(status_class, "Invalid status code") 735 message = message.format(self, error_type=error_type) --> 736 raise HTTPStatusError(message, request=request, response=self) HTTPStatusError: Redirect response '302 Found' for url 'https://solidcommunity.net/login/password' Redirect location: 'https://solidrive.solidcommunity.net/' For more information check: https://httpstatuses.com/302Looking at the source, the cause is in
auth.py
:I think this broke in https://github.com/twonote/solid-file-python/pull/29, when dependabot bumped the version of httpx. In the previous version (httpx 0.18.2),
raise_for_status
used to only raise an exception if the status code was a 4xx code (https://github.com/encode/httpx/blob/0.18.2/httpx/_models.py#L1384). In the newer version (httpx 0.23.0),raise_for_status
raises an exception if the status is not a 2xx code, which includes redirects (https://github.com/encode/httpx/blob/0.23.0/httpx/_models.py#L701)The code in
auth.py
should probably be wrapped in: