CropPath for developers

All guides

OAuth2 client credentials

Available

OAuth2 client credentials authentication for company integrations.

Company integrations authenticate with OAuth2 client credentials (RFC 6749 §4.4). A tenant admin, signed in, registers an API client in the settings (Integrations, or POST /v1/oauth-clients): a name, a role (tenant_admin, operator or auditor), the scopes it may use and, for the operator role, optionally the facilities it is limited to. The client id starts with agc_; the secret starts with acs_ and is shown once.

Your integration exchanges its id and secret for an access token at POST /v1/oauth/token: a form body with grant_type=client_credentials and, optionally, scope (names separated by spaces; without it, all of the client's scopes). Authenticate the client with HTTP Basic, or with the client_id and client_secret body fields, never both. The answer holds access_token (ago_...), token_type Bearer, expires_in 900 (15 minutes) and the scope granted; send the token as Authorization: Bearer, and ask for a new one when it expires. The Go, Java and .NET SDKs request, cache and renew the token for you.

curl -sS https://<host>/v1/oauth/token \
  -u "$CROPPATH_CLIENT_ID:$CROPPATH_CLIENT_SECRET" \
  -d grant_type=client_credentials \
  --data-urlencode "scope=lot_read lot_write"
# {"access_token": "ago_...", "token_type": "Bearer", "expires_in": 900, "scope": "lot_read lot_write"}

A scope is the name of one route permission and implies no other: a token opens an operation only when it holds that operation's scope and the client's role allows it; anything else is 403 role not permitted. The API reference lists every scope and, on each operation an API client may call, the scope it needs. epcis_capture and records_export are granted only by name, never through another scope.

Revoking the client ends all of its tokens at once; POST /v1/oauth/revoke (RFC 7009) revokes one token. A client holds at most 20 live tokens (429 beyond that) and a tenant at most 50 live clients. Errors follow RFC 6749: invalid_client (401), invalid_scope, invalid_request, unsupported_grant_type. API tokens (agt_...) keep working and have no scopes.

In the API reference

Downloads

This portal serves these files: you do not need access to the source repository.