【发布时间】:2016-02-22 17:21:58
【问题描述】:
我一直在尝试使用 OAuth 2.0 连接到 Exact Online。我们倾向于专注于 Java 应用程序,遗憾的是 Exact 没有 Java 的文档/示例/支持。
我能够进行身份验证请求,但是对于令牌请求,我遇到了一些麻烦。我的代码:
OAuthAuthzResponse oar = OAuthAuthzResponse.oauthCodeAuthzResponse(request);
code = oar.getCode();
OAuthClientRequest oAuthRequest;
try {
oAuthRequest = OAuthClientRequest
.tokenLocation("https://start.exactonline.be/api/oauth2/token")
.setGrantType(GrantType.AUTHORIZATION_CODE)
.setClientId(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)
.setRedirectURI(REDIRECT_URI)
.setCode(code)
.buildQueryMessage();
OAuthClient client = new OAuthClient(new URLConnectionClient());
OAuthJSONAccessTokenResponse oauthResponse = client.accessToken(oAuthRequest, OAuth.HttpMethod.POST);
}
我环顾四周,但我找到的所有答案都没有解决问题。
- 尝试使用其他令牌响应类型。
- 尝试使用 .buildBodyMessage 而不是 .buildQueryMessage
我总是得到其中 1 个 ProblemExceptions:
Token request failed: unsupported_response_type, Invalid response! Response body is not application/json encoded
Token request failed: invalid_request, Missing parameters: access_token
我希望任何人都具有处理精确在线问题的经验,感谢任何帮助。
【问题讨论】:
-
OAuth 错误是标准化的,参见 RFC:tools.ietf.org/html/rfc6749
标签: java oauth oauth-2.0 oltu exact-online