View Single Post
  #10 (permalink)  
Old 04-09-2010, 04:27 AM
vmahajan vmahajan is offline
Zimbra Employee
 
Posts: 70
Default

I tried using your oauth provider extension. It worked till the point where I get the access token and secret. But when I try to access the protected resource using this access token I get a signature invalid exception.

Here's the code I use to get the access token:


OAuthConsumer consumer = new DefaultOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);

OAuthProvider provider = new DefaultOAuthProvider(REQUEST_TOKEN_ENDPOINT_URL,
ACCESS_TOKEN_ENDPOINT_URL,
AUTHORIZE_WEBSITE_URL);

String userAuthzUrl = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);
System.out.println(userAuthzUrl);

Scanner scanner = new Scanner(System.in);
System.out.println("Verification code: ");
provider.retrieveAccessToken(consumer, scanner.nextLine());


And Here's the code to access the protected resource:


OAuthConsumer consumer = new DefaultOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
// use the access token obtained above
consumer.setTokenWithSecret("2110f8fea7c799cecfa5c e931206e589", "38a4114222a2c2417a4bda12027f7634");
URL protRscUrl = new URL("http://localhost:4444/home/user1/inbox.rss");
HttpURLConnection connection = (HttpURLConnection) protRscUrl.openConnection();
consumer.sign(connection);
connection.connect();
connection.getInputStream();


The exception I get is:

net.oauth.OAuthProblemException: signature_invalid

from SimpleOAuthRevAValidator.validateSignature() method.

Any idea why I am getting this error?

Thanks!
Reply With Quote