For security reasons, Evernote javascript api does not normally work on any browsers.
This application works as a proxy server and allows you to use evernote-sdk-js on a pure client side application.
REF
Does the API support CORS (Cross origin resource sharing)
-
Get Evernote API Consumer Key and Consumer Secret from here.
-
Copy
config.json.templatetoconfig.jsonand fill in your values. -
Install dependencies.
$ npm install
-
Start server
$ node server.js -
Access to
http://localhost:9999/oauth?callbackurl=http://xxx.html
Changehttp://localhost:9999andcallbackurlvaluehttp://xxx.htmlaccording to your environment. -
You will be redirected to Evernote authentication page.
-
When authentication is successful, you will be redirected to
http://xxx.htmlwith the query paramoauthAccessToken.NOTE The
oauthAccessTokenis encoded, so you have to decode it bydecodeURIComponentfunction. -
You can use
oauthAccessTokenforevernote-sdk-jsby usinghttp://localhost:9999/noteStore?oauthAccessToken=yyyasnoteStoreURL. -
See also Sample client and REDME.md of "Evernote SDK for JavaScript".
You can see all functions ofNoteStorehere.
Below is a simple application to get the oauthAccessToken and to show notebook list.
Before using it, download evernote-sdk-minified.js and store it at js/ directory.
evernote-sdk-minified.js can be downloaded from production directory of evernote-sdk-js.
<!DOCTYPE html>
<html>
<head>
<script src="js/evernote-sdk-minified.js"></script>
<script type="text/javascript">
function getParameter(name) {
var regex = new RegExp(name + "=(.+?)(&|$)");
try {
return decodeURIComponent(regex.exec(location.search)[1]);
} catch (e) {
return undefined;
}
}
// TODO change to valid server
var proxyServerAddr = "http://localhost:9999";
var oauthAccessToken = getParameter("oauthAccessToken");
if (!oauthAccessToken) {
var selfAddr = window.location.href.replace(/window.location.search/, "");
// redirect to auth page
window.location.href = proxyServerAddr + "/oauth" + "?callbackurl=" + selfAddr;
} else {
var noteStoreURL = proxyServerAddr + "/noteStore" + "?oauthAccessToken=" + oauthAccessToken;
var noteStoreTransport = new Thrift.BinaryHttpTransport(noteStoreURL);
var noteStoreProtocol = new Thrift.BinaryProtocol(noteStoreTransport);
var noteStore = new NoteStoreClient(noteStoreProtocol);
// Get the notebook list and display on console.
noteStore.listNotebooks(oauthAccessToken,
function(notebooks) {
console.log(notebooks);
},
function (error) {
console.log(error.errorCode + ": " + error.parameter);
});
}
</script>
</head>
</html>-
Create a new Heroku app
heroku apps:create APP_NAME -
Provide API_CONSUMER_KEY and API_CONSUMER_SECRET:
heroku config:set API_CONSUMER_KEY=XXXX API_CONSUMER_SECRET=YYYY -
Push changes to heroku
git push heroku master
OR
heroku restart
I decided to make this app for StackEdit and consulted Gatekeeper.