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:
objectManages 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 toUS.
- 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:
- invalidate()[source]¶
Force the next
get_access_token()call to refresh the token.- Return type:
None
- classmethod from_env()[source]¶
Build
ZohoPeopleAuthfrom 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: