Let admin-client acquire new token if refresh_token is stale
This commit is contained in:
1 parent
08e1f455e2
commit
8dfc7d9e8d
1 file changed
+8
-4
+8
-4
@@ -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() {
|
||||
|
||||
Reference in new issue
Block a user