I need to create an application with Mendeley in Java. But I have problems with the oauth2's conexion.
I use Apache Oltu, but if you know another better alternative, told me please.
I have this:
OAuthClientRequest request = OAuthClientRequest
.tokenLocation("https://api-oauth2.mendeley.com/oauth/token")
.setGrantType(GrantType.AUTHORIZATION_CODE)
.setClientId(CLIENT_ID)
.setClientSecret(CLIENTE_SECRET)
.setRedirectURI(REDIRECT_URI)
.setCode("code")
.setScope("all")
.buildQueryMessage();
OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
GitHubTokenResponse oAuthResponse = oAuthClient.accessToken(request, GitHubTokenResponse.class);
String accessToken = oAuthResponse.getAccessToken();
String expiresIn = oAuthResponse.getExpiresIn().toString();
System.out.println("ACCESS TOKEN: " + accessToken);
System.out.println("EXPIRES IN : " + expiresIn);
but this produces this exception:
Exception in thread "main" OAuthProblemException{error='invalid_request', description='Missing parameters: access_token', uri='null', state='null', scope='null', redirectUri='null', responseStatus=0, parameters={}}
at org.apache.oltu.oauth2.common.exception.OAuthProblemException.error(OAuthProblemException.java:59).......
Any idea? I repeat, if you know another alternative or solution help me please.
Thanks a lot.