I'm attempting to use OAuth authentication to connect to a variety of services. For this most part, this works (tested with twitter/photobucket), but with evernote, I'm receiving a 400 response code.
What's wrong here?
OAuthConsumer consumer = new DefaultOAuthConsumer( "myConsumerKey", "myConsumerSecret" );
OAuthProvider provider = new DefaultOAuthProvider( "https://sandbox.evernote.com/oauth", "https://sandbox.evernote.com/oauth", "https://sandbox.evernote.com/OAuth.action" );
String authUrl = provider.retrieveRequest( consumer, OAuth.OUT_OF_BAND );
This works for Twitter + Photobucket, so why not evernote? I'm using Signpost 1.2, which has been great except for this one provide开发者_如何学JAVAr.
Most likely the signer. Evernote only supports plain text signing. You may also receive a 405, if that's the case override the createRequest
method to use a GET instead of POST.
AuthConsumer consumer = new DefaultOAuthConsumer( "myConsumerKey", "myConsumerSecret" );
consumer.setMessageSigner( new PlainTextMessageSigner() );
OAuthProvider provider = new DefaultOAuthProvider( "https://sandbox.evernote.com/oauth", "https://sandbox.evernote.com/oauth", "https://sandbox.evernote.com/OAuth.action" );
String authUrl = provider.retrieveRequest( consumer, OAuth.OUT_OF_BAND );
BTW, I got this answered through the community support forums, I'm not smart enough to figure it out on my own. ;-)
We recently added support for HMAC-SHA1 signing, so you shouldn't need to change the messageSigner anymore. You will need to use GET instead of POST. More information is available from our forum post.
精彩评论