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

hc-login not following 307 redirects #35

Open
jorritolthuis opened this issue Dec 10, 2023 · 0 comments
Open

hc-login not following 307 redirects #35

jorritolthuis opened this issue Dec 10, 2023 · 0 comments

Comments

@jorritolthuis
Copy link

It seems that the server sometimes presents redirects using status code 302, and sometimes using 307. The former is properly handled, the latter is not.

Tested on macOS 14.1.2 and Python 3.11, results in the following (shortened) debug output:

--------
return_url='https://singlekey-id.com/auth/connect/authorize/callback?client_id=[...]', <Response [302]> 
return_url='https://singlekey-id.com/auth/login?returnUrl=%2Fauth%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3D[...]', <Response [302]> 
return_url='https://singlekey-id.com/auth/en-gb/login?returnUrl=%2Fauth%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3D[...]', <Response [307]> 
return_url='https://singlekey-id.com/auth/en-gb/login?returnUrl=%2Fauth%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3D[...]'
--------
Traceback (most recent call last):
  File "/Users/jorrit/Documents/Projects/home_control_py/./hc-login", line 188, in <module>
    code = query.get("code")[0]
           ~~~~~~~~~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable

The 302 redirect is properly handled, but the loop is ended upon a 307. This means the remaining code runs on the wrong URL, and crashes.

Changing line 168 seems to resolve this:
if r.status_code != 302 and r_status_code != 307:

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