Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/auth-standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,18 @@ async function performOAuth(credentials: Credentials) {
china: false
});

const noteStoreUrl = authenticatedClient.getNoteStore().url;

// Get user info to verify token
try {
const userStore = authenticatedClient.getUserStore();
const user = await userStore.getUser();

// getNoteStore().url is undefined here; getUserUrls() returns the
// real noteStoreUrl, falling back to deriving from webApiUrlPrefix.
const userUrls = await userStore.getUserUrls();
const noteStoreUrl = userUrls?.noteStoreUrl
|| (results.edam_webApiUrlPrefix
? results.edam_webApiUrlPrefix.replace(/\/$/, '') + '/notestore'
: undefined);

const tokenData = {
token: accessToken,
noteStoreUrl,
Expand Down
11 changes: 10 additions & 1 deletion src/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,16 @@ export class EvernoteOAuth {
if (!tokens.noteStoreUrl) {
try {
const userStore = authenticatedClient.getUserStore();
const noteStoreUrl = await userStore.getNoteStoreUrl();
// The Evernote JS SDK (evernote@2.0.5) has no getNoteStoreUrl(); use
// getUserUrls(), and fall back to deriving from webApiUrlPrefix.
const userUrls = await userStore.getUserUrls();
const noteStoreUrl = userUrls?.noteStoreUrl
|| (tokens.webApiUrlPrefix
? tokens.webApiUrlPrefix.replace(/\/$/, '') + '/notestore'
: undefined);
if (!noteStoreUrl) {
throw new Error('UserStore returned no noteStoreUrl');
}
tokens.noteStoreUrl = noteStoreUrl;
if (!process.env.EVERNOTE_ACCESS_TOKEN && !(this.isClaudeCode && process.env.OAUTH_TOKEN)) {
await fs.writeFile(this.tokenFile, JSON.stringify(tokens, null, 2));
Expand Down
Loading