Authentication
Getting access tokens for your service account.
Use Obtain an oauth token (POST /oauth/token) to exchange your service account's client ID and secret for an access token and a refresh token, and then once the access token is about to expire, use Obtain an oauth token (POST /oauth/token) with the refresh token to get a new access token and refresh token. See Authentication for the full flow.
Obtain an oauth token
POST /oauth/token
Exchange client credentials or refresh token for an access token.
Supports three methods:
- Client credentials via HTTP Basic Auth (Authorization header) with
grant_type=client_credentialsin body. - Client credentials in form-urlencoded request body with
grant_type=client_credentials. - Refresh token in form-urlencoded request body with
grant_type=refresh_token.
curl
curl -X POST "https://api.zympler.com/v1beta/oauth/token" \
-u "$ZYMPLER_CLIENT_ID:$ZYMPLER_CLIENT_SECRET" \
-d 'grant_type=client_credentials'Rust
let response = reqwest::Client::new()
.post("https://api.zympler.com/v1beta/oauth/token")
.basic_auth(&client_id, Some(&client_secret))
.form(&[("grant_type", "client_credentials")])
.send()
.await?
.error_for_status()?;
let body: serde_json::Value = response.json().await?;Python
response = requests.post(
"https://api.zympler.com/v1beta/oauth/token",
auth=(client_id, client_secret),
data={
"grant_type": "client_credentials",
},
timeout=30,
)
response.raise_for_status()
data = response.json()Request body
application/x-www-form-urlencoded (required)
One of: ClientCredentialsGrantBody
| Field | Type | Required | Description |
|---|---|---|---|
grant_type | string: client_credentials | yes | |
client_id | string | yes | |
client_secret | string (password) | yes |
Or: RefreshTokenGrantBody
| Field | Type | Required | Description |
|---|---|---|---|
grant_type | string: refresh_token | yes | |
refresh_token | string (password) | yes |
Or: GrantTypeBody
| Field | Type | Required | Description |
|---|---|---|---|
grant_type | string: client_credentials | yes |
Responses
Fields
| Field | Type | Required | Description |
|---|---|---|---|
access_token | string | yes | Bearer token to be used as authentication for other API calls |
token_type | string: Bearer | yes | |
expires_in | integer (uint64) | yes | Number of seconds until the token expires |
refresh_token | string | yes | Refresh token to get a new access_token when this one expires |
Status codes
| Status | Description |
|---|---|
200 | Ok |
400 | Bad Request |
401 | Unauthorized |