Evernote SDK:对共享笔记本进行身份验证

Evernote SDK: Authenticate to shared notebook

我正在尝试使用 Evernote Android SDK 访问共享笔记本。我从应用程序的服务器端通过 REST api 接收 shareKey。我正在使用以下代码:

AuthenticationResult result = EvernoteSession.getInstance()
                    .getEvernoteClientFactory()
                    .getNoteStoreClient()
                    .authenticateToSharedNotebook(shareKey);
            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);

但是当我打电话给

AuthenticationResult result = EvernoteSession.getInstance()
                        .getEvernoteClientFactory()
                        .getNoteStoreClient()
                        .authenticateToSharedNotebook(shareKey);

它抛出一个异常

EDAMNotFoundException(identifier:SharedNotebook.id, key:39116)

我做错了什么?我如何接受共享和访问共享笔记本的内容?

你用错了sharedNotebookStoreUrl

ASharedNotebook是A账号到B账号的aNotebookN的一份分享记录,存放在A账号(笔记本N)的noteStoreUrl中。账户 B 将有一个对应的 LinkedNotebook 记录指向 SharedNotebook(不是笔记本)。 LinkedNotebook 将在帐户 B 上。

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

听起来你在帐户 B 中并试图访问笔记本 N。你想要做的是从 LinkedNotebook L 中获取 noteStoreUrl,然后使用它来调用 authenticateToSharedNotebook。您可以通过调用 listLinkedNotebooks.

来获取 LinkedNotebooks

不确定这是否适用于您的具体情况,但您可以尝试以下操作在用户 B 的帐户中创建链接笔记本(我在稍微不同的情况下做了类似的事情):

LinkedNotebook linkedNotebook = new LinkedNotebook();
linkedNotebook.SharedNotebookGlobalId = <the shareKey you got from the server>
linkedNotebook.ShareName = <the name of the Shared Notebook>
linkedNotebook.Username = <the username of user A; i.e. the owner of the Shared Notebook>
linkedNotebook.ShardId = <the shardId of the notebook in user A's account>
LinkedNotebook createdLinkedNotebook = noteStore.createLinkedNotebook(authenticationToken, linkedNotebook);