Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

I am using the OAUTH2.0  RSS feed

Gajendra Gaja
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using the OAUTH2.0 with below code,

OAuthServiceProvider provider = new OAuthServiceProvider(requestTokenURL, authorizationURL, accessTokenURL);
OAuthConsumer consumer = new OAuthConsumer("OAuth ", consumerKey, consumerSecret, provider);
OAuthAccessor accessor = new OAuthAccessor(consumer);
OAuthClient client = new OAuthClient(new HttpClient4());
List<Parameter> parameters = new ArrayList<OAuth.Parameter>();

parameters.add(new Parameter(ImsLtiLaunchParamDataKeys.OAUTH_CALLBACK, callBackUrl));
byte[] hash = DigestUtils.sha(IOUtils.toByteArray(new ByteArrayInputStream(body.getBytes())));
String b64 = new String(Base64.encodeBase64(hash),"UTF-8");

parameters.add(new Parameter(ImsLtiLaunchParamDataKeys.OAUTH_BODY_HASH, b64));
parameters.add(new Parameter("oauth_consumer_secret", consumerSecret));

OAuthMessage request = accessor.newRequestMessage(OAuthMessage.POST,requestTokenURL,parameters,new ByteArrayInputStream(body.getBytes()));

OAuthMessage msg =client.invoke(request, ParameterStyle.AUTHORIZATION_HEADER);

Our application getting following exception,

at net.oauth.client.OAuthResponseMessage.toOAuthProblemException(
Please any one can help me.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!