Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keycloak returning already-expired tokens

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?

like image 384
janwr Avatar asked Sep 01 '25 03:09

janwr


1 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?

like image 164
brouille Avatar answered Sep 03 '25 00:09

brouille