use of org.apache.oltu.oauth2.client.HttpClient in project vcita-platform-java-sdk by SimonIT.
the class ApiClient method initHttpClient.
private void initHttpClient(List<Interceptor> interceptors) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.addNetworkInterceptor(getProgressInterceptor());
for (Interceptor interceptor : interceptors) {
builder.addInterceptor(interceptor);
}
httpClient = builder.build();
}
use of org.apache.oltu.oauth2.client.HttpClient in project vcita-client-java-sdk by SimonIT.
the class ApiClient method initHttpClient.
private void initHttpClient(List<Interceptor> interceptors) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.addNetworkInterceptor(getProgressInterceptor());
for (Interceptor interceptor : interceptors) {
builder.addInterceptor(interceptor);
}
httpClient = builder.build();
}
use of org.apache.oltu.oauth2.client.HttpClient in project javlo by Javlo.
the class AbstractSocialNetwork method getSocialUser.
public SocialUser getSocialUser(HttpServletRequest request) {
HttpClient httpClient = null;
try {
httpClient = new URLConnectionClient();
OAuthClient oAuthClient = new OAuthClient(httpClient);
OAuthAuthzResponse oar = OAuthAuthzResponse.oauthCodeAuthzResponse(request);
String code = oar.getCode();
String accessToken = getAccessToken(code, oAuthClient);
TransientUserInfo.getInstance(request.getSession()).setToken(accessToken);
return getSocialUser(accessToken, oAuthClient);
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (httpClient != null) {
httpClient.shutdown();
}
}
}
use of org.apache.oltu.oauth2.client.HttpClient in project lusid-sdk-java by finbourne.
the class ApiClient method initHttpClient.
private void initHttpClient(List<Interceptor> interceptors) {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.addNetworkInterceptor(getProgressInterceptor());
for (Interceptor interceptor : interceptors) {
builder.addInterceptor(interceptor);
}
httpClient = builder.build();
}
use of org.apache.oltu.oauth2.client.HttpClient in project javlo by Javlo.
the class AbstractSocialNetwork method performRedirect.
@Override
public void performRedirect(HttpServletRequest request, HttpServletResponse response, boolean admin) {
HttpClient httpClient = null;
try {
httpClient = new URLConnectionClient();
OAuthClient oAuthClient = new OAuthClient(httpClient);
OAuthAuthzResponse oar = OAuthAuthzResponse.oauthCodeAuthzResponse(request);
String code = oar.getCode();
String accessToken = getAccessToken(code, oAuthClient);
TransientUserInfo.getInstance(request.getSession()).setToken(accessToken);
SocialUser user = getSocialUser(accessToken, oAuthClient);
if (user == null || user.getEmail() == null || user.getEmail().isEmpty()) {
logger.warning("OAuth login failed with provider: " + getName());
return;
}
ContentContext ctx = ContentContext.getContentContext(request, response);
login(ctx, user, admin);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (httpClient != null) {
httpClient.shutdown();
}
}
}
Aggregations