0

我正在尝试为 Exact online Netherlands 设置 REST API 客户端。我正在使用 Oltu 库进行 OAuth 授权。这是我的代码:

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());

但是,我收到invalid_request 错误

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)

有人可以取悦我吗?

4

1 回答 1

0

最后它非常简单。只需要耐心;)

所以发布答案。

只需关注此博客https://www.jasha.eu/blogposts/2013/09/retrieve-facebook-profile-data-java-apache-oltu.html

于 2018-08-16T17:19:40.347 回答