Merge pull request #1193 from behana/master
Let admin-client acquire new token if refresh_token is stale
This commit is contained in:
commit
10998eb35b
1 changed files with 8 additions and 4 deletions
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue