K_query_bearer_token - 404 after token expires

I am using expose-token=true in to adapter config and using /k_query_bearer_token call to get the token on UI.

But after some time, this starts giving 404 ( Looks like due to Access Token Lifespan ) .

How can I force it to refresh token in case of 404 or avoid this error.

Update: I am using keycloak spring boot adapter in backend. I am getting token for logged in user and want to use that token for api calls

@prashantch80 Did you find a solution for this?