Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findNotesMetadata() Returning { "errorCode": 3, "parameter": "authenticationToken" } In NodeJs #105

Open
MhdSadd opened this issue Jan 16, 2022 · 0 comments

Comments

@MhdSadd
Copy link

MhdSadd commented Jan 16, 2022

Using evernote's JS-SDK I've been successful in authenticating and authorizing third party client and fetching their notebooks, But when trying to search note using search queries i kept getting { "errorCode": 3, "parameter": "authenticationToken" } even though oauthAccessToken is present in user session. I have tried passing in the accessToken directly as parameter to findNotesMetadata() but that gives me "Incorrect number of arguments passed to findNotesMetadata: Expected 4 but found 5"

StackOverflow isn't helping as the same issue was reported 2 years ago and there was no answer. Below is the API code for GET request to /search

exports.searchNote = async (req, res) => {
  if (req.session.oauthAccessToken) {
    console.log(SESSION =>", req.session);

    const token = req.session.oauthAccessToken;
    const searchParam = req.query.search;
    console.log("ACCESS_TOKEN =>", token);
    console.log("SEARCH_WORD =>", searchParam);
    const client = new Evernote.Client({
      consumerKey: config.API_CONSUMER_KEY,
      consumerSecret: config.API_CONSUMER_SECRET,
      token: token,
      sandbox: config.SANDBOX,
      china: config.CHINA,
    });
    const noteStore = client.getNoteStore();    
    const filter = new Evernote.NoteStore.NoteFilter({
      words: searchParam === undefined ? "" : searchParam,
      ascending: true,
    });
    const spec = new Evernote.NoteStore.NotesMetadataResultSpec({
      includeTitle: true,
      includeContentLength: true,
      includeCreated: true,
      includeUpdated: true,
      includeDeleted: true,
      includeUpdateSequenceNum: true,
      includeNotebookGuid: true,
      includeTagGuids: true,
      includeAttributes: true,
      includeLargestResourceMime: true,
      includeLargestResourceSize: true,
    });

    noteStore
      .findNotesMetadata(filter, 0, 500, spec)
      .then((notesMetadataList) => {
        // data.notes is the list of matching notes
        console.log(notesMetadataList);
        res.json({ NotesMetaData: notesMetadataList });
      })
      .catch((err) => {
        console.log("Search_Error =>", err);
        res.status(500).json({ Search_Error: err });
      });
  } else {
    res.status(401).json({
      session: req.session,
      msg: "You do not have an active session, login and authorize NoteTaker to access your Evernote Account",
    });
  }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant