メインコンテンツにスキップ

Zotero credentials

R/auth.R

cz_auth

Description

Resolves the library ID and API key, by default from the environment variables ZOTERO_LIBRARY_ID and ZOTERO_API_KEY. Set them once with cz_set_auth(), or load them yourself (e.g. from a gitignored .Renviron or .env.local). citezot never reads credential files; only cz_set_auth() writes the key, and only when you ask it to. The key is never printed.

Usage

cz_auth(
  library_id = NULL,
  api_key = Sys.getenv("ZOTERO_API_KEY"),
  library_type = c("user", "group")
)

Arguments

Arguments Description
library_id Numeric user ID (or group ID), as a string or number. If NULL (default), taken from ZOTERO_LIBRARY_ID.
api_key Zotero API key.
library_type "user" (personal library) or "group".

Details

Create a key at https://www.zotero.org/settings/keys; the numeric user ID is on the same page. A read-only key is enough for cz_fetch_items(); only functions that change the library need a key with write access.

Value

A cz_auth object, for the auth argument of other functions.

Examples

# Explicit values (normally these come from environment variables). The key
# is never shown when the object is printed.
cz_auth(library_id = "1234567", api_key = "not-a-real-key")
<cz_auth> user library 1234567 (API key hidden)