Keycloak returning already-expired tokens

Viewed 1126

I'm trying to use keycloak to get access tokens,

but I get the error Token is expired when trying to use the tokens issued by keycloak

For example, if I get a token using curl:

curl -u account:___mysecret___ -k
-d "grant_type=password&username=testuser&password=__some__pass"
-H "Content-Type:application/x-www-form-urlencoded" 
http://localhost:8080/auth/realms/testRealm/protocol/openid-connect/token

and decode the returned token using jwt.io, I can see that the exp date is yesterday's date.

how do I get usable access tokens?

2 Answers

I think you were using keycloak with docker desktop on windows.

And your localtime of your hyperV where not synchronize anymore with your host computer.

If you wrote : date in your docker container, the date is wrong.

So the token genreate by keycloak was outdated

So rebooting hyperV resynchronize the localtime in your docker container.

More info here : How to make sure docker's time syncs with that of the host?

Checked in the "realm settings" the "tokens" tab! There you can configure session timeout and token validity.

Further check in "clients" => "settings" => "advanced settings" if there is set something.

Then please check the time and time zone configured on you keycloak host.

Related