Gleb Eremeev Gleb Eremeev - 6 months ago 19
Android Question

Evernote SDK: Authenticate to shared notebook

I'm trying to gain access to shared notebook using Evernote Android SDK. I'm receiving shareKey via REST api from server side of the applicaiton. I'm using the code below:

AuthenticationResult result = EvernoteSession.getInstance()
String token = result.getAuthenticationToken();
String sharedNotebookStoreUrl = result.getNoteStoreUrl();
TBinaryProtocol sharedNoteProtocol = new TBinaryProtocol(
new THttpClient(sharedNotebookStoreUrl));
NoteStore.Client sharedNoteStore = new NoteStore.Client(sharedNoteProtocol);
SharedNotebook sharedNotebook = sharedNoteStore.getSharedNotebookByAuth(token);

But when I call

AuthenticationResult result = EvernoteSession.getInstance()

it trows an exception

EDAMNotFoundException(, key:39116)

What I am doing wrong? How I can accept sharing and access to shared notebook's content?


You're using the wrong sharedNotebookStoreUrl.

A SharedNotebook is the record of a share of a Notebook N from account A to account B. It is stored in the noteStoreUrl of account A (notebook N). Account B will have a corresponding LinkedNotebook record that points to the SharedNotebook (not the notebook). The LinkedNotebook will be on account B.

NoteStoreUrl for account A            NoteStoreUrl for account B
Notebook N                            LinkedNotebook L (points to S)
SharedNotebook S (points to N)

Sounds like you're in account B and trying to access the Notebook N. What you want to do is fetch the noteStoreUrl from the LinkedNotebook L and then use that to call authenticateToSharedNotebook. You can fetch the LinkedNotebooks by calling listLinkedNotebooks.