marcospereirampj / python-keycloak

MIT License
704 stars 297 forks source link

KeycloakOpenIDConnection 404 error #522

Open yingfeic opened 6 months ago

yingfeic commented 6 months ago

Hi, I got a 404 error when trying to connect keycloak. I can ping the keycloak ip successfully from my machine. And the keycloak admin interface works (http://:9080/auth). Suggestions are highly appreciated.

Thank you so much for your help!

===== from keycloak import KeycloakAdmin from keycloak import KeycloakOpenIDConnection

keycloak_connection = KeycloakOpenIDConnection( server_url="http://:9080/auth/", username='admin', password=password, realm_name="cbioportal", user_realm_name="admin", client_id="account", client_secret_key="f542.....617e", verify=True)

Error message: Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.8/site-packages/keycloak/openid_connection.py", line 119, in init self.get_token() File "/usr/local/lib/python3.8/site-packages/keycloak/openid_connection.py", line 320, in get_token self.token = self.keycloak_openid.token( File "/usr/local/lib/python3.8/site-packages/keycloak/keycloak_openid.py", line 319, in token return raise_error_from_response(data_raw, KeycloakPostError) File "/usr/local/lib/python3.8/site-packages/keycloak/exceptions.py", line 192, in raise_error_from_response raise error( keycloak.exceptions.KeycloakPostError: 404: b''

ShavaShav commented 6 months ago

Having the same issue.

Edit: This was the issue for me: https://github.com/marcospereirampj/python-keycloak/issues/149 If the keycloak url ends in /auth, then you need to append a trailing / (e.g. http://:9080/auth/ instead of http://:9080/auth)