0

I am trying to setup REST API client for Exact online Netherlands. I am using Oltu library for OAuth authorization. Here is my code:

OAuthAuthzResponse oar = OAuthAuthzResponse.oauthCodeAuthzResponse(httpReq);
  String code = oar.getCode();
  System.out.println(code);
  OAuthClientRequest oAuthRequest;
  oAuthRequest = OAuthClientRequest
          .tokenLocation("https://start.exactonline.nl/api/oauth2/token")
          .setGrantType(GrantType.AUTHORIZATION_CODE)
          .setClientId("CLIEN_ID_HERE")
          .setClientSecret("SECRET_HERE")
          .setRedirectURI("http://localhost:8080/exact/returnTo")
          .setCode(code)
          .buildBodyMessage();


  OAuthClient client = new OAuthClient(new URLConnectionClient());

  OAuthJSONAccessTokenResponse oauthResponse = client.accessToken(oAuthRequest, OAuth.HttpMethod.POST);
  LOGGER.info(oauthResponse.getAccessToken());

However, I am getting invalid_request error

org.apache.oltu.oauth2.common.exception.OAuthProblemException: invalid_request
    at org.apache.oltu.oauth2.common.exception.OAuthProblemException.error(OAuthProblemException.java:59)
    at org.apache.oltu.oauth2.client.validator.OAuthClientValidator.validateErrorResponse(OAuthClientValidator.java:63)

Can someone please me ?

Venky
  • 474
  • 1
  • 6
  • 17

1 Answers1

0

In the end it was very simple. just needed to be patient ;)

So posting answer.

Just follow this blog https://www.jasha.eu/blogposts/2013/09/retrieve-facebook-profile-data-java-apache-oltu.html

Venky
  • 474
  • 1
  • 6
  • 17