fix: resolve noteStoreUrl via getUserUrls() (SDK has no getNoteStoreUrl)#42
Merged
jack-arturo merged 1 commit intoJun 6, 2026
Conversation
…etNoteStoreUrl() The Evernote JS SDK (evernote@2.0.5) has no UserStore.getNoteStoreUrl() method. When a token is loaded without a cached noteStoreUrl (e.g. the file-based .evernote-token.json flow), getAuthenticatedClient() in oauth.ts called the missing method, threw, and surfaced the misleading "Token may be invalid" error — breaking every tool call. auth-standalone.ts had the matching write-side bug: getNoteStore().url returns undefined, so it persisted a token file with noteStoreUrl unset, guaranteeing the read-side failure later. Both now use the real userStore.getUserUrls().noteStoreUrl, with a fallback that derives the URL from webApiUrlPrefix (<prefix>/notestore). Env-var auth paths (EVERNOTE_NOTESTORE_URL / OAUTH_NOTESTORE_URL) are unaffected. Verified against a live account: a token with no noteStoreUrl now fetches successfully (715 notes) and persists the resolved URL back. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Member
|
Thanks @jayzuccarelli ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With file-based auth (
.evernote-token.json, i.e. the Claude Desktop / non-env-var path), every tool call fails with:The token isn't actually invalid. Root cause is a method that doesn't exist in the bundled SDK:
src/oauth.ts): when a loaded token has no cachednoteStoreUrl,getAuthenticatedClient()callsuserStore.getNoteStoreUrl().evernote@2.0.5has nogetNoteStoreUrl()method — UserStore exposesgetUser,getUserUrls,getPublicUserInfo, etc. The call throws and gets rethrown as the misleading "Token may be invalid".src/auth-standalone.ts):authenticatedClient.getNoteStore().urlreturnsundefined, so the standalone OAuth flow persists a token file withnoteStoreUrlunset — guaranteeing the read-side failure on the next run.Env-var auth (
EVERNOTE_NOTESTORE_URL/OAUTH_NOTESTORE_URL) supplies the URL directly and so masks the bug, which is likely why it's gone unnoticed.Fix
Use the real SDK method
userStore.getUserUrls().noteStoreUrl, with a fallback that derives it fromwebApiUrlPrefix(<prefix>/notestore). Applied on both the read and write paths.Verification
Tested against a live production account:
noteStoreUrl→ server now fetches successfully and returns notes (715 results on atravelsearch), and persists the resolvednoteStoreUrlback to the token file.userStore.getUserUrls().noteStoreUrlreturnshttps://www.evernote.com/shard/sXXX/notestore, matching the derived fallback.npm run build(tsc) clean; eslint clean on both files.🤖 Generated with Claude Code