Skip to content

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

@MhdSadd

Description

@MhdSadd

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",
    });
  }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions