I get an issue from oltu(version 0.31)
. I can get code and access_token
successfully. But, if I access protect resource, the error said: invalid access token
. when I print resourceResponse.getBody()
still said invalid access token. If change to httpclient
or httpURLConnection
all is fine. Would you please tell me what am I wrong in my code
public String getUserInfo(String accessToken) throws OAuthSystemException, OAuthProblemException {
System.out.println("Get User info access Token: " + accessToken);
OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
System.out.println("111111111111111111111");
OAuthClientRequest bearerClientRequest = new OAuthBearerClientRequest(OauthConfig.userInfo).setAccessToken(accessToken).buildQueryMessage();
System.out.println("22222222222222222222222");
OAuthResourceResponse resourceResponse = oAuthClient.resource(bearerClientRequest, OAuth.HttpMethod.GET, OAuthResourceResponse.class);
System.out.println("3333333333333333333333333");
System.out.println(resourceResponse.getBody());
return resourceResponse.getBody();
}
Closed this question. I found issue. my server access Token name is "accessToken", but oltu default name is "access_token". So, need to inheritance the OAuthBearerClientRequest and re-code all method.