[keycloak-user] updateToken method not working

Stian Thorgersen stian at redhat.com
Fri Oct 31 03:18:26 EDT 2014


That looks correct to me. 

Looks like for some reason the token refresh isn't successful. The default session idle timeout is pretty low so it could be that. Try increasing 'SSO Session Idle Timeout' in the admin console (Session and Tokens -> Timeout Settings) to make sure that's not the problem.

We don't currently pass the error details to the error method, which we should, but you can look at the actual request http using your a dev console to see if there's any details in the response to why the refresh fails.

----- Original Message -----
> From: "Dean Peterson" <peterson.dean at gmail.com>
> To: keycloak-user at lists.jboss.org
> Sent: Thursday, 30 October, 2014 8:57:51 PM
> Subject: [keycloak-user] updateToken method not working
> 
> I use the following code to make sure I have a valid token before making a
> request. Even though I am logged in, if I wait until the token expires then
> make a request, the error function is called most of the time when I try to
> update the token using the updateToken method. I have the page reload, and I
> have a valid token again. However, I did not have to log in again because
> the session had not expired. I am using 1.1.0-Alpha1-SNAPSHOT I have read
> the documentation. Am I missing something?
> 
> keycloak.updateToken().success(function() {
> if (data) {
> $http({
> url: ' http://localhost:8080 ' + url,
> method: method,
> data: data,
> headers: {
> 'Content-Type': contentType,
> 'Accept': acceptType,
> 'Authorization': 'Bearer ' + service.auth.token
> },
> transformRequest: angular.identity
> }).success(success).error(error);
> } else {
> $http({
> url: ' http://localhost:8080 ' + url,
> method: method,
> headers: {
> 'Content-Type': contentType,
> 'Accept': acceptType,
> 'Authorization': 'Bearer ' + service.auth.token
> }
> }).success(success).error(error);
> }
> }).error(function() {
> alert("Token could not be refreshed!");
> location.reload();
> });
> 
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user


More information about the keycloak-user mailing list