javascriptnode.jsevernote

Evernote authentification with developer token failed


I'm writing totally simple JS code to connect to the Evernote sandbox, which is pretty the same as the one in the documentation:

const Evernote = require("evernote");

const client = new Evernote.Client({
  token: "here-is-my-developer-token1234",
  sandbox: true
});

const userStore = client.getUserStore();

userStore.getUser().then(function(user) {
  console.log(user)
});

Though, I get an error about the CORS policy, which, I suppose, means that my authentification failed for some reason:

Access to fetch at 'https://sandbox.evernote.com//edam/user' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I've got my token from there: https://sandbox.evernote.com/api/DeveloperToken.action

Perhaps there is something basic I'm missing. Any guidance would be appreciated.


Solution

  • As you can see in JS SDK docs, they do not support CORS, that is, header authentification as well. So you will need to use oauth.