Search code examples
javaoauthevernotesignpost

OAuth Authentication with Evernote (Using Java+Signpost)


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 provider.


Solution

  • 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. ;-)