---
title: "Authorization"
description: "In order to integrate with our CM.com Online Payments API you need to be authorized. The current authorization process follows the standard OAuth 2.0 client credentials flow:"
canonical: "https://docs.cm.com/payments/online-payments/guides/authorization"
---

# Authorization

> In order to integrate with our CM.com Online Payments API you need to be authorized. The current authorization process follows the standard OAuth 2.0 client credentials flow:

Source: https://docs.cm.com/payments/online-payments/guides/authorization

In order to integrate with our CM.com Online Payments API you need to be authorized. The current authorization process follows the standard OAuth 2.0 client credentials flow:

## Client Credentials Flow

The Client Credentials Flow ([defined in OAuth 2.0 RFC 6749, section 4.4](https://datatracker.ietf.org/doc/html/rfc6749#section-4.4)) requires an application exchanging its application credentials (`clientID` and `clientSecret`) for an access token. The access token should be provided as a `Bearer` token in the Authorization header on subsequent calls to the API.

### How does it work?

In the diagram above the following steps are performed:

1. You make a request to [Get an access token](https://docs.cm.com/payments/online-payments/guides/authorization#get-an-access-token).  This is a request to our public `oauth2/token` API endpoint using the API credentials (clientID and clientSecret) provided by CM.
2. If you get a successful response an `access_token` will be retrieved. The `access_token` has a lifetime (indicated by `expires_in` on the retrieved response), so you can use the same `access_token` as `Bearer` token in several subsequent calls to the API as long as the token is not expired. If the token expires **there is no refresh token in this flow**, so you should do a new request to [Get an access token](https://docs.cm.com/payments/online-payments/guides/authorization#get-an-access-token), receive a new `access_token` and repeat this step.

You do not have reinvent the wheel in your code because there are already known OAuth2 libraries in many languages that automate this: [OAuth libraries](https://oauth.net/code/).

## Get an Access token

### Request

```curl title="Get an Access token - Example Request"
curl -X POST \
--url https://api.pay.cm.com/api/v1/authorization/oauth2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Accept: application/json' \
--data-urlencode 'client_id=<string>' \
--data-urlencode 'client_secret=<string>' \
--data-urlencode 'grant_type=client_credentials'
```

### Request parameters

| Name | Type | Description |
| :- | :- | :- |
| client\_id | String | This is part of the API credentials provided by CM. |
| client\_secret | String | This is part of the API credentials provided by CM. |
| grant\_type | String | This is a fixed value: 'client\_credentials' |

### Response

```json title="Get an Access token - Example Response"
{
  "access_token": "EXAMPLE_ACCESS_TOKEN",
  "expires_in": 3600,
  "token_type": "Bearer"
}
```

### Response parameters

| Name | Type | Description |
| :- | :- | :- |
| access\_token | String | **This is the access token that you use as a `Bearer` token in subsequent API calls.** |
| expires\_in | Int | The lifetime in seconds of the access token. If the token expires **there is no refresh token in this flow**, so you should do a new request to [Get an access token](https://docs.cm.com/payments/online-payments/guides/authorization#get-an-access-token) . |
| token\_type | String | This is a fixed value: 'Bearer' |

## Make API calls using Access token as `Bearer` token

Once you made the request to [Get an access token](https://docs.cm.com/payments/online-payments/guides/authorization#get-an-access-token) you can use the retrieved `access_token` as `Bearer` token in your subsequent API calls as long as the token is not expired.

Example, given `"access_token": "EXAMPLE_ACCESS_TOKEN"` we make an API call to create a checkout transaction using the  `access_token` as `Bearer` in the Authorization header:

```curl title="Make API call using Access token - Example"
curl -X POST \
--url https://api.pay.cm.com/api/v1/paymentmethods/checkout/v1/transactions \
--header 'Authorization: Bearer EXAMPLE_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
  ...
  ...
```
