Keycloak: All API response with 404
Asked Answered
W

2

6

I followed this tutorial to setup Keycloak and create user but the response for the step of Generating Access Tokens With Keycloak's API 404. I'm using Keycloak version 18.0.0

In the logs of keycloak I found this error

2022-06-12 23:59:57,177 DEBUG [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-3) Error response 404: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8080/auth/realms/test/protocol/openid-connect/token

enter image description here

Wiese answered 12/6, 2022 at 21:59 Comment(5)
Without your endpoint-code it is hard to determine. Maybe the REST-Method is not post? Or something in the path is wrong?Colza
I has no code. It just a setup from keycloak admin consoleWiese
The URL for generation token in Keycloak is localhost:8080/auth/realms {{realmName}}/protocol/openid-connect/tokenWiese
Are you sure it is configured to run on port 8080? the tutorial is running on a different portInsatiable
I can access the admin console using this url localhost:8080Wiese
R
7

404 Error means the URL of the resource does not exist.

You did set in Headers instead of Body. Move the Key & Values to Body.enter image description here

In Keycloak version 18

You can verify Token URL by click "OpenID Endpoint Configuration" link enter image description here

It will show Token URL enter image description here

In Keycloak version 21

enter image description here

OIDC Well-Known Configuration Endpoint

Returns the OpenID Connect configuration values from the Keycloak's Well-Known Configuration Endpoint

GET /.well-known/openid-configuration
http://localhost:8080/realms/[your realm]/.well-known/openid-configuration

Token End Point

http://localhost:8080/realms/[your realm]/protocol/openid-connect/token

enter image description here

Get Access Token by Postman. enter image description here

Rescission answered 12/6, 2022 at 23:1 Comment(3)
I moved them and still got 404Wiese
As @Unattended have mentioned you need to remove the authEdelmiraedelson
Thanks @dreamcrash, I added a picture how to verify Token URL.Rescission
U
12

From keycloak 17+ there are changes in resource or token URIs. Try removing auth from your request URL.

If you are using Keycloak version < 17

curl -k -H "Content-Type: application/x-www-form-urlencoded" -d "client_id=your-client" -d "username=some-user" -d "password=hardpassword" -d "grant_type=password" -X POST http://localhost:8080/auth/realms/yourrealm/protocol/openid-connect/token

If you are using Keycloak version > 17

curl -k -H "Content-Type: application/x-www-form-urlencoded" -d "client_id=your-client" -d "username=some-user" -d "password=hardpassword" -d "grant_type=password" -X POST http://localhost:8080/realms/yourrealm/protocol/openid-connect/token

Unattended answered 13/6, 2022 at 8:36 Comment(0)
R
7

404 Error means the URL of the resource does not exist.

You did set in Headers instead of Body. Move the Key & Values to Body.enter image description here

In Keycloak version 18

You can verify Token URL by click "OpenID Endpoint Configuration" link enter image description here

It will show Token URL enter image description here

In Keycloak version 21

enter image description here

OIDC Well-Known Configuration Endpoint

Returns the OpenID Connect configuration values from the Keycloak's Well-Known Configuration Endpoint

GET /.well-known/openid-configuration
http://localhost:8080/realms/[your realm]/.well-known/openid-configuration

Token End Point

http://localhost:8080/realms/[your realm]/protocol/openid-connect/token

enter image description here

Get Access Token by Postman. enter image description here

Rescission answered 12/6, 2022 at 23:1 Comment(3)
I moved them and still got 404Wiese
As @Unattended have mentioned you need to remove the authEdelmiraedelson
Thanks @dreamcrash, I added a picture how to verify Token URL.Rescission

© 2022 - 2024 — McMap. All rights reserved.