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"
I'd seen the same question asked here 2 years ago but didn't get any answer, Any form of help is welcome. Below is my current code
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",
});
}
};