2

I am writing a posting engine to run on Glassfish which posts to Twitter from a database queue.

I am using the Scribe Java API for doing this. I am having an issue with performing a signRequest from the OAuthService. I have a valid access token and have the tweet to send out - Below is my code for where the error is occuring.

String urlTweet = "https://api.twitter.com/1.1/statuses/update.json?status=Tweet To Post";

OAuthRequest tmpRequest = new OAuthRequest(Verb.POST, urlTweet);
oAuthService.signRequest(accessToken, tmpRequest); // THIS LINE THERE IS AN ERROR
response = tmpRequest.send();

However I am getting an error on the line shown above. Here is the stack trace for what I am getting - parts have been redacted for anonymity purposes.

org.scribe.exceptions.OAuthSignatureException: Error while signing string: POST&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fupdate.json&[redacted]
    at org.scribe.services.HMACSha1SignatureService.getSignature(HMACSha1SignatureService.java:36)
    at org.scribe.oauth.OAuth10aServiceImpl.getSignature(OAuth10aServiceImpl.java:151)
    at org.scribe.oauth.OAuth10aServiceImpl.addOAuthParams(OAuth10aServiceImpl.java:75)
    at org.scribe.oauth.OAuth10aServiceImpl.signRequest(OAuth10aServiceImpl.java:126)
    at [redacted].TWScribePost.postTwitter(TWScribePost.java:141)
    at [redacted].Post.TWScribePost.post(TWScribePost.java:42)
    at [redacted].Post.PostingEng$TWReadQueue.run(PostingEng.java:137)
    at java.util.TimerThread.mainLoop(Unknown Source)
    at java.util.TimerThread.run(Unknown Source)
Caused by: java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available
    at javax.crypto.Mac.getInstance(DashoA13*..)
    at org.scribe.services.HMACSha1SignatureService.doSign(HMACSha1SignatureService.java:43)
    at org.scribe.services.HMACSha1SignatureService.getSignature(HMACSha1SignatureService.java:32)
    ... 8 more
Zach Ross-Clyne
  • 779
  • 3
  • 10
  • 35

1 Answers1

0

Try to use response = oAuthService.execute(tmpRequest); instead of response = tmpRequest.send();

zoubair Omar
  • 106
  • 1
  • 5