laurent22/joplin · error · Error

User is not authenticated

Error message

User is not authenticated

What it means

Thrown by SyncTargetOneDrive.initSynchronizer() when isAuthenticated() returns false. Like Dropbox, OneDrive sync requires valid OAuth credentials; without them the Synchronizer is not constructed. The catch block dispatches a SYNC_REPORT_UPDATE with the error before re-throwing, so it surfaces in the sync report UI.

Source

Thrown at packages/lib/SyncTargetOneDrive.ts:131

			}
			Setting.setValue(`sync.${this.syncTargetId()}.context`, JSON.stringify(context));
		}
		api.setAccountProperties(accountProperties);
		const appDir = await this.api().appDirectory();
		// the appDir might contain non-ASCII characters
		// /[^\u0021-\u00ff]/ is used in Node.js to detect the unescaped characters.
		// See https://github.com/nodejs/node/blob/bbbf97b6dae63697371082475dc8651a6a220336/lib/_http_client.js#L176
		// eslint-disable-next-line prefer-regex-literals -- Old code before rule was applied
		const baseDir = RegExp(/[^\u0021-\u00ff]/).exec(appDir) !== null ? encodeURI(appDir) : appDir;
		const fileApi = new FileApi(baseDir, new FileApiDriverOneDrive(this.api()));
		fileApi.setSyncTargetId(this.syncTargetId());
		fileApi.setLogger(this.logger());
		return fileApi;
	}

	public async initSynchronizer() {
		try {
			if (!(await this.isAuthenticated())) throw new Error('User is not authenticated');
			return new Synchronizer(this.db(), await this.fileApi(), Setting.value('appType'));
		} catch (error) {
			BaseSyncTarget.dispatch({ type: 'SYNC_REPORT_UPDATE', report: { errors: [error] } });
			throw error;
		}


	}
}

View on GitHub (pinned to 2654b33620)

Solutions

  1. Re-run the OneDrive OAuth flow from Joplin's Synchronisation settings.
  2. In your Microsoft account's Connected apps, remove Joplin and re-authorise to get a fresh token.
  3. If on a work/school account, confirm conditional-access/MFA policies allow the Joplin app.
  4. Sync again after a successful authorisation.

Example fix

// before: initSynchronizer() throws; sync report shows 'User is not authenticated'
// after: Tools -> Synchronisation -> target: OneDrive -> re-authorise -> Synchronise
Defensive patterns

Strategy: validation

Validate before calling

// Gate sync on OneDrive auth before constructing the synchronizer.
const authed = await syncTarget.isAuthenticated();
if (!authed) throw new Error('OneDrive token missing/expired — re-authorise');

Type guard

const isOneDriveAuthed = async (target) => await target.isAuthenticated() === true;

Try / catch

try { await syncTarget.initSynchronizer(); }
catch (e) { if (/User is not authenticated/.test(e.message)) { /* re-run OneDrive OAuth flow */ } else throw e; }

Prevention

When it happens

Trigger: initSynchronizer() calls isAuthenticated() which returns false — token missing, expired, or revoked.

Common situations: User selected OneDrive but never finished OAuth; token expired after 90 days of inactivity; token revoked in Microsoft account settings; corporate OneDrive with conditional-access policies blocking the app.

Understand the failure class

Related errors


AI-assisted analysis of laurent22/joplin@2654b33620 (2026-08-12). Data as JSON: /api/errors/1e435771c00d66d2. Report an issue: GitHub.