我正在尝试为 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)
有人可以取悦我吗?