I have been trying to use OAuth 2.0 to connect to Exact Online. We tend to focus on Java-applications and sadly Exact doesn't have documentation/examples/support for Java.
I was able to do the authentication request but for the token request I'm having some trouble. My code:
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);
}
I've looked around but all the answers I've found didn't solve the problem.
- Tried to use the other tokenresponse types.
- Tried using .buildBodyMessage instead of .buildQueryMessage
I always get 1 of these 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
I was hoping anyone has prior experience dealing with exact online, any help is appreciated.