OAuth 2.0 - Client credentials grant flow

In the client credentials flow, the Apaleo Identity API verifies your app’s client ID and client secret, then issues an access token directly to the app. The app acts on its own behalf without a user sign-in.

Use this grant for a custom integration with one hotel account. Register a separate simple client and use separate credentials for each account you integrate with. Apaleo Store apps use the installation grant for organization-level apps or the authorization code grant for user apps. See Which OAuth 2.0 grant works best for me?.

Use this flow for a client that can keep its credentials confidential, such as a server-side application. Keep the client secret in a secure store.

How it works

  1. Request an access token from the Apaleo Identity API using your client credentials.
  2. Call the Apaleo APIs with the access token.

Prerequisites

Create a client app and get client credentials

Register a simple client under Apps → Connected apps in the hotel account the integration will access.

Choose the client access type during registration.

Client access type What to configure
Fine-grained client (recommended) Select the permissions your app needs for each API. Under Property access, choose All properties for the account’s current and future properties, or Only selected properties and select at least one. The same permissions apply to every property the client can access.
Scope client Select the API scopes your app needs. The scopes apply across the account.

The client access type is permanent. You can edit the client’s scopes or permissions after registration. To change the client access type, register a new client. See Scopes and permissions.


Step 1. Client requests an access token

Post to the token endpoint using HTTP Basic authentication. Encode clientId:clientSecret as Base64 and send it in the Authorization header.

POST https://identity.apaleo.com/connect/token
Authorization: Basic {base64(clientId:clientSecret)}
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials

Use the same request for both client access types. Omit the scope parameter. Apaleo includes the client’s registered scopes for a scope client. For a fine-grained client, API access comes from the permissions and properties configured on the client.

Example cURL request

Set CLIENT_ID and CLIENT_SECRET to your simple client’s credentials in a Bash-compatible shell. The --user option supplies the credentials for HTTP Basic authentication.

curl --request POST 'https://identity.apaleo.com/connect/token' \
  --user "$CLIENT_ID:$CLIENT_SECRET" \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data 'grant_type=client_credentials'

Token response

Apaleo returns a JSON response with these fields.

Field Description
access_token The bearer token to send with Apaleo API requests.
expires_in The token’s lifetime in seconds. A value of 3600 is one hour.
token_type Bearer.
scope The space-separated scopes for a scope client. A fine-grained client receives the marker identity:permissions.

Scope client

{
  "access_token": "{accessToken}",
  "expires_in": 3600,
  "token_type": "Bearer",
  "scope": "availability.read reservations.read"
}

Fine-grained client

{
  "access_token": "{accessToken}",
  "expires_in": 3600,
  "token_type": "Bearer",
  "scope": "identity:permissions"
}

For a fine-grained client, check the client’s configured permissions and property access to determine which operations it can call. The identity:permissions marker indicates that Apaleo uses fine-grained access.

Decoded JWT examples

The aud claim lists the token’s intended audiences. The fine-grained example includes audiences for additional Apaleo APIs. Each API checks the access required by the operation.

Scope client

{
  "nbf": 1591448890,
  "exp": 1591452490,
  "iss": "https://identity.apaleo.com",
  "aud": ["api", "identity_server", "notifications", "apaleo"],
  "client_id": "SDXE-SP-SIMPLEAPP",
  "account_code": "SDXE",
  "scope": ["availability.read", "reservations.read"]
}

Fine-grained client

{
  "nbf": 1591448890,
  "exp": 1591452490,
  "iss": "https://identity.apaleo.com",
  "aud": [
    "api", "identity_server", "notifications", "apaleo",
    "integration", "fiscalization", "profile", "rendering",
    "distribution", "scheduler", "config", "payment"
  ],
  "client_id": "SDXE-SP-FGASIMPLEAPP",
  "account_code": "SDXE",
  "scope": ["identity:permissions"]
}

Renew the access token

Cache the token and reuse it until it approaches expiry. Use expires_in to determine when to repeat the client credentials request. This flow issues a new access token through the same request without a refresh token.


Step 2. Start making REST API calls

Send the access token in the Authorization header as a bearer token. The example retrieves the property with ID MUC. Replace it with a property ID for your account.

A fine-grained client needs core.properties.read and access to the requested property. For a scope client, this operation requires a valid access token and has no specific scope requirement. See the Core API reference.

GET https://api.apaleo.com/inventory/v1/properties/MUC
Authorization: Bearer {accessToken}

Example cURL request

Set ACCESS_TOKEN to the access_token from Step 1.

curl --include \
  --header "Authorization: Bearer $ACCESS_TOKEN" \
  'https://api.apaleo.com/inventory/v1/properties/MUC'

Example response

The example shows selected fields from the response.

{
  "id": "MUC",
  "code": "MUC",
  "name": {
    "en": "Hotel Munich"
  },
  "timeZone": "Europe/Berlin",
  "currencyCode": "EUR"
}

Troubleshoot API access

Status What to check
401 Unauthorized Check that the request sends a valid access token in the Authorization header. Request a new token if it has expired.
403 Forbidden Check the scope or permission the operation requires. For a fine-grained client, also check access to the property in the client’s configuration.

See Scopes and permissions to look up an operation’s access requirements.