From 8dfc7d9e8d0f822cb5611f1382de2f37373bedca Mon Sep 17 00:00:00 2001 From: behana Date: Wed, 29 Apr 2015 05:01:59 +0200 Subject: [PATCH] Let admin-client acquire new token if refresh_token is stale --- .../keycloak/admin/client/token/TokenManager.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java index 4e694ebc6e..d31d6e8ebc 100644 --- a/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java +++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/token/TokenManager.java @@ -7,6 +7,7 @@ import org.keycloak.admin.client.Config; import org.keycloak.admin.client.resource.BasicAuthFilter; import org.keycloak.representations.AccessTokenResponse; +import javax.ws.rs.BadRequestException; import javax.ws.rs.core.Form; import java.util.Calendar; import java.util.Date; @@ -76,10 +77,13 @@ public class TokenManager { TokenService tokenService = target.proxy(TokenService.class); - AccessTokenResponse response = tokenService.refreshToken(config.getRealm(), form.asMap()); - - defineCurrentToken(response); - return response; + try { + AccessTokenResponse response = tokenService.refreshToken(config.getRealm(), form.asMap()); + defineCurrentToken(response); + return response; + } catch (BadRequestException e) { + return grantToken(); + } } private void setExpirationTime() {