use of org.apache.oltu.oauth2.client.request.OAuthClientRequest.AuthenticationRequestBuilder in project components by Talend.
the class Oauth2ImplicitClient method getAuthorizationCode.
private String getAuthorizationCode() {
try {
AuthenticationRequestBuilder builder = OAuthClientRequest.authorizationLocation(authorizationLocation.toString()).setClientId(clientID).setRedirectURI(callbackURL.toString());
if (responseType != null) {
builder.setResponseType(responseType);
}
OAuthClientRequest request = builder.buildQueryMessage();
// FIXME : remove those Syso when the studio activate the INFO log by default
System.out.println(messages.getMessage("msg.info.showAuthorizUrl"));
System.out.println(request.getLocationUri());
// --
logger.info(messages.getMessage("msg.info.showAuthorizUrl"));
logger.info(request.getLocationUri());
OAuth2ImplicitGrantServer service = new OAuth2ImplicitGrantServer(callbackURL.getHost(), callbackURL.getPort(), 10 * 60 * 1000);
// <--- this method wait for 10 minutes maximum to grab authorization code
service.run();
String code = service.getAuthorizationCode();
service.stop();
return code;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations