我正在尝试为确切的荷兰在线设置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)
有人可以取悦我吗?
答案 0 :(得分:0)
最后,这非常简单。只是需要耐心;)
所以发布答案。
只需关注此博客https://www.jasha.eu/blogposts/2013/09/retrieve-facebook-profile-data-java-apache-oltu.html