Question

I want to develop a evernote sync function in my java application.

So I download source code as evernote told me and mvn it correctly get the jar package.

And I download scribe-java too. I want to use scribe java to get oauth token.

I was so happy when I saw there is a evernoteapi class in scribe-java.

But I got an exception like that:

" org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this:

'<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=9,chrome=1" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="Shortcut Icon" href="/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="/redesign/global/css/reset.css" />

<link rel="stylesheet" href="/redesign/global/css/fonts.css" media="all" />

<link rel="stylesheet" href="/redesign/global/css/header.css" />
<link rel="stylesheet" href="/redesign/global/css/layout.css" />

<title>Evernote Error</title>
</head>
<body>
  <div class="header">
    <div class="logo-bar">
      <a class="evernote-logo" href="https://sandbox.evernote.com/Home.action?/">Evernote</a></div>
  </div>
  <div id="container-boundingbox" class="wrapper">
    <div id="container" class="wrapper">
      <div class="main">
        <div class="page-header">
          <h1>
            Oops, we encountered an error.</h1>
        </div>
        <div>
          <p>
            Sorry, we've encountered an unexpected error.</p>
        </div>
        <div class="clear"></div>
      </div>
    </div>
    <div class="shadow wrapper">
      <img src="/redesign/global/img/desktop-shadow-full.png" />
    </div>
    <div class="footer wrapper">
      <a class="footer-entry" href="https://sandbox.evernote.com/Home.action?/tos/">Terms of Service</a><a class="footer-entry" href="https://sandbox.evernote.com/Home.action?/privacy/">Privacy Policy</a><span class="footer-entry last">Copyright 2014 Evernote Corporation. All rights reserved.</span>
    </div>
  </div>
</body>
</html>'

"

This exception is raised at line Token requestToken = service.getRequestToken();:

         OAuthService service = new ServiceBuilder()
        .provider(EvernoteApi.Sandbox.class)
        .apiKey("your key")
        .apiSecret("your secret")
        .build();

         Token requestToken = service.getRequestToken();

         String authUrl = service.getAuthorizationUrl(requestToken);

I have googled it and have no idea still...

Was it helpful?

Solution

I guess you are missing callback URL.

  OAuthService service = new ServiceBuilder()
    .provider(EvernoteApi.Sandbox.class)
    .apiKey("YOUR CONSUMER_KEY")
    .apiSecret("YOUR CONSUMER_SECRET")
    .callback("YOUR CALLBACK URL")
    .build();

You can also see how it works with this sample app.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top