Auth

OAuth 2.0 authentication for Zoho People.

Supports:
  • Static access token (short-lived, ~1h)

  • Auto-refresh via client_id + client_secret + refresh_token (recommended)

  • Construction from environment variables via ZohoPeopleAuth.from_env()

Example:

auth = ZohoPeopleAuth(
    client_id="1000.xxx",
    client_secret="yyy",
    refresh_token="1000.zzz",
    data_centre="EU",
)
# or
auth = ZohoPeopleAuth.from_env()
class zoho_people.auth.ZohoPeopleAuth(client_id=None, client_secret=None, refresh_token=None, access_token=None, data_centre='US')[source]

Bases: object

Manages OAuth 2.0 tokens for Zoho People API.

Parameters:
  • client_id (str, optional) – OAuth client ID (1000.xxx).

  • client_secret (str, optional) – OAuth client secret.

  • refresh_token (str, optional) – Long-lived refresh token.

  • access_token (str, optional) – Short-lived access token. Automatically refreshed when expired.

  • data_centre (str) – Zoho data centre: US | EU | IN | AU | JP. Defaults to US.

client_id: str | None = None
client_secret: str | None = None
refresh_token: str | None = None
access_token: str | None = None
data_centre: str = 'US'
property accounts_url: str

OAuth accounts base URL for the configured data centre.

property base_url: str

Zoho People API base URL for the configured data centre.

property can_refresh: bool

True when refresh credentials are present.

get_access_token()[source]

Return a valid access token, refreshing it automatically when needed.

Raises:

ZohoPeopleAuthError – If no token is available and refresh credentials are missing.

Return type:

str

auth_header()[source]

Return the Authorization header dict.

Return type:

dict[str, str]

invalidate()[source]

Force the next get_access_token() call to refresh the token.

Return type:

None

classmethod from_env()[source]

Build ZohoPeopleAuth from environment variables.

Reads: ZOHO_CLIENT_ID, ZOHO_CLIENT_SECRET, ZOHO_REFRESH_TOKEN, ZOHO_PEOPLE_ACCESS_TOKEN, ZOHO_DATA_CENTRE.

Raises:

ZohoPeopleAuthError – If neither an access token nor full refresh credentials are set.

Return type:

ZohoPeopleAuth