Commit 3ebc42f9 authored by Matija Obreza's avatar Matija Obreza

Throw OAuthException when refresh token no longer valid

parent 4e9423a0
......@@ -24,6 +24,7 @@ import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.genesys2.client.oauth.GenesysApiException;
import org.scribe.builder.api.DefaultApi20;
import org.scribe.exceptions.OAuthException;
import org.scribe.extractors.AccessTokenExtractor;
import org.scribe.extractors.JsonTokenExtractor;
import org.scribe.model.OAuthConfig;
......@@ -162,6 +163,8 @@ public class GenesysApi extends DefaultApi20 {
_log.debug("Redirect: " + response.getHeader(HttpHeaders.LOCATION));
if (response.getCode() >= 200 && response.getCode() < 300) {
return getAccessTokenExtractor().extract(response.getBody());
} else if (response.getCode() == 400) {
throw new OAuthException("Refresh token no longer valid.");
} else {
throw new GenesysApiException("Server responded with unexpected HTTP response code " + response.getCode());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment