0

I'm developing a Windows client for some integration with Evernote desktop. In particular, I need to build locale (in-app) links to notes, which requires the userId and shardId (evernote:///view/[userId]/[shardId]/[noteGuid]/[noteGuid]/). Problem is, I don't find how to programmatically get userId and shardId. I need to use ENSessionAdvanced instead of ENSession, and I will authenticate to Evernote by an API key, as follows:

ENSessionAdvanced.SetSharedSessionConsumerKey("key", "secret");
if (!ENSessionAdvanced.SharedSession.IsAuthenticated)
    ENSessionAdvanced.SharedSession.AuthenticateToEvernote();

From there, I could get notebooks and notes, and everything, but no idea of where to get userId and shardId. Help!

Vico
  • 196
  • 1
  • 7
  • I believe you're working with [this sdk](https://github.com/evernote/evernote-cloud-sdk-windows/blob/master/samples/CS/SampleApp/SampleApp/Form1.cs) is that correct? Does `ENSessionAdvanced.SharedSession.AuthenticateToEvernote();` return anything? – Jimmy Smith Feb 10 '20 at 14:48
  • Precisely nothing. – Vico Feb 10 '20 at 15:47
  • This link https://dev.evernote.com/doc/articles/note_links.php says "The shardId can be obtained by calling the getUser method on the userStore object" but no idea of how to get the "userStore" object... I can get the ENSessionAdvanced.SharedSession.PrimaryNoteStore but it's different from UserStore. – Vico Feb 10 '20 at 15:49
  • https://dev.evernote.com/doc/reference/UserStore.html - looks like it might take you further, but are you sure `ENSessionAdvanced.SharedSession.AuthenticateToEvernote();` doesn't return an object `AuthenticationResult`? Try something like `var result = ENSessionAdvanced.SharedSession.AuthenticateToEvernote();` and see what result gives you to work with. – Jimmy Smith Feb 10 '20 at 16:33
  • No trace of UserStore, using ENSessionAdvanced, @JimmySmith. And no AuthenticationResult. But... maybe I've got a track... – Vico Feb 11 '20 at 21:22
  • EN.EDAM.Type.Notebook seems to have a "Contact" property, which is... the user. No trace of doc, on Evernote, but it seems it. Contact.Id and Contact.ShardId. So...`EN.EDAM.Type.Note note = this.store.GetNote(noteGuid, false, false, false, false); EN.EDAM.Type.Notebook notebook = this.store.GetNotebook(note.NotebookGuid); return "evernote:///view/" + notebook.Contact.Id + "/" + notebook.Contact.ShardId + "/" + noteGuid + "/" + noteGuid + "/";` – Vico Feb 11 '20 at 21:27
  • 1
    Seems the solution and it compiles but still not tested. Problems with connection now but that's another problem... I'll post the solution as soon as I have it working. Thanks, @JimmySmith! – Vico Feb 11 '20 at 21:29
  • I'm glad to help. Make sure you post as I feel this one needs more documentation. – Jimmy Smith Feb 11 '20 at 22:03
  • 1
    Indeed, @JimmySmith. But I'm stuck with authentication, now, and Evernote support totally absent... [Auth problem](https://stackoverflow.com/questions/60185006/problem-authenticating-to-evernote-with-net-sdk) – Vico Feb 12 '20 at 09:30
  • I wonder what in the chain IS keeping the session properties as that's all we need to crack into. I'd think it would be something easily accessible from `ENSessionAdvanced.SharedSession` – Jimmy Smith Feb 12 '20 at 14:25

0 Answers0