javaoauthopenid-connectoltu

Apache Oltu OAuthClient.accessToken() fails with timeout


I'm trying to login users using Google OpenID.

When I try to authenticate a user, I always run into a timeout when trying to retrieve the AccessToken.

public class TestRun {
    public static void main(String args[]) throws OAuthSystemException, OAuthProblemException {
        OAuthClientRequest request = OAuthClientRequest
                .tokenProvider(OAuthProviderType.GOOGLE)
                .setGrantType(GrantType.AUTHORIZATION_CODE)
                .setCode("")
                .setRedirectURI(Env.REST_API_LOCATION+"/login")
                .setClientId(Env.CLIENT_ID)
                .setClientSecret(Env.CLIENT_SECRET)
                .buildQueryMessage();

        OAuthClient oac = new OAuthClient(new URLConnectionClient());
        OAuthAccessTokenResponse response = oac.accessToken(request);
        System.out.println(response.getAccessToken());
        System.out.println(response.getExpiresIn());
    }
}

I always run into a ConnectException (timeout) when oac.accessToken(request) is called and don't get any more info about what's happening.


Solution

  • So, the problem is simple. The system on which my software runs is accessible from the internet, but outbound traffic is forced to use a proxy. As the proxy isn't a transparent one, I had to write my own implementation of HttpClient which is able to deal with a proxy and replace URLConnectionClient with it.