use of feign.FeignException.BadRequest in project vcert-java by Venafi.
the class TppTokenConnector method authenticate.
@Override
public void authenticate(Authentication auth) throws VCertException {
if (isEmptyCredentials(auth))
throw new MissingCredentialsException();
try {
AuthorizeTokenRequest authRequest = new AuthorizeTokenRequest(auth.user(), auth.password(), auth.clientId(), auth.scope(), auth.state(), auth.redirectUri());
AuthorizeTokenResponse response = tpp.authorizeToken(authRequest);
tokenInfo = new TokenInfo(response.accessToken(), response.refreshToken(), response.expire(), response.tokenType(), response.scope(), response.identity(), response.refreshUntil(), true, null);
this.credentials = auth;
this.credentials.accessToken(tokenInfo.accessToken());
this.credentials.refreshToken(tokenInfo.refreshToken());
} catch (Unauthorized | BadRequest e) {
tokenInfo = new TokenInfo(null, null, -1, null, null, null, -1, false, e.getMessage() + " " + new String(e.content()));
}
}
Aggregations