When the Zotero desktop application is not running — or is otherwise unreachable — the connector falls back to saving bibliographic items directly to the user’s zotero.org library via the Zotero Web API v3. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/zotero/zotero-connectors/llms.txt
Use this file to discover all available pages before exploring further.
Zotero.API singleton (src/common/api.js) implements an OAuth 1.0a authorisation flow using the OAuthSimple library (src/common/oauthsimple.js), then uses the obtained API key to create items and upload file attachments.
When the Web API is Used
ItemSaver.saveItems() calls _saveToZotero() first. If that call throws with status === 0 (the connector server is offline), it falls back to _saveToServer(), which uses Zotero.API:
Access to the zotero.org Web API requires a Zotero account. Users who have not yet authenticated are prompted to log in during their first save attempt when the desktop client is offline.
OAuth 1.0a Configuration
All OAuth endpoints and client credentials are defined inZOTERO_CONFIG:
OAuthSimple (src/common/oauthsimple.js), which implements the standard HMAC-SHA1 signature method.
OAuth Flow: Zotero.API.authorize()
authorize() implements the full three-legged OAuth 1.0a dance:
Request temporary token
A signed
POST is sent to OAUTH.ZOTERO.REQUEST_URL using the client key and secret. The response contains an oauth_token and oauth_token_secret (the temporary credentials).Open authorisation window
The user is redirected to the Zotero authorisation page. The URL is built from A browser window (900 × 600) is opened and the promise returned by
AUTHORIZE_URL with the signed token and scopes:authorize() is left pending.Handle the callback: onAuthorizationComplete()
When the user approves access, zotero.org redirects to
CALLBACK_URL. The connector intercepts the redirect and calls Zotero.API.onAuthorizationComplete(data, tab).The callback:- Exchanges the temporary token for permanent access credentials via
ACCESS_URL. - Verifies the key has
user.libraryanduser.writepermissions by callingGET /users/<id>/keys/currentwith headerZotero-API-Key. - Stores credentials in preferences:
auth-token,auth-token_secret,auth-userID,auth-username.
User Info: Zotero.API.getUserInfo()
Returns stored OAuth credentials as an object, or null if the user has not yet authorised:
auth-token_secret, auth-userID, and auth-username.
Creating Items: Zotero.API.createItem(payload, askForAuth?)
Posts items to the user’s library using the stored API key:
askForAuth is not false, createItem() automatically clears stored credentials and restarts the OAuth flow.
An array of item objects in the Zotero API JSON format, produced by
Zotero.Utilities.Item.itemToAPIJSON().When
false, throws immediately if not authorised instead of starting the OAuth flow. Used in retry chains to prevent infinite loops.Uploading Attachments: Zotero.API.uploadAttachment(attachment)
File upload uses the Zotero Web API’s two-phase upload protocol:
Authorise upload
A
POST to /users/<id>/items/<key>/file with If-None-Match: * and URL-encoded file metadata requests an upload authorisation. If the server responds { "exists": 1 }, the file is already uploaded and no further action is required.Upload binary data
The authorisation response provides
prefix, suffix, url, contentType, and uploadKey. The attachment data is wrapped:The required properties for
uploadAttachment are data (a typed array / ArrayBuffer), key (item key — alphanumeric only), md5, and mimeType. The md5 hash is computed by Zotero.ItemSaver.md5() using an embedded implementation derived from pdf.js.Clearing Credentials: Zotero.API.clearCredentials()
Removes all stored OAuth tokens from preferences:
Credential Storage Summary
| Preference Key | Content |
|---|---|
auth-token | OAuth access token (public) |
auth-token_secret | OAuth token secret / API key (used for all API calls) |
auth-userID | Numeric Zotero user ID |
auth-username | Zotero username (displayed in the connector UI) |
Further Reading
All API requests include theZotero-API-Version: 3 header. Rate limits are enforced server-side; the connector does not currently implement client-side backoff for 429 responses when saving via the Web API.