> For the complete documentation index, see [llms.txt](https://developers.make.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.make.com/api-documentation/authentication/oauth-flow/authorization-code-flow-with-refresh-token-confidential-clients.md).

# Authorization code flow with refresh token (confidential clients)

**Use this flow when:** Your application can securely store a Client Secret (server-side applications).

**Benefits:** Provides both access tokens and refresh tokens for long-term access.

{% stepper %}
{% step %}

#### Redirect user for authorization

Redirect the user to the authorization endpoint:

```
GET https://www.make.com/oauth/v2/authorize
```

**Required parameters:**

* `client_id`: Your application's Client ID
* `response_type`: Set to `code`
* `redirect_uri`: Pre-registered callback URL
* `scope`: Requested permissions (include `openid` for OpenID Connect)
* `state`: Random string for CSRF protection (recommended)

**Example URL:**

```
https://www.make.com/oauth/v2/authorize?  client_id=your_client_id&  response_ty
```

{% endstep %}

{% step %}

#### User authorization

The user:

1. Logs into Make.com (if not already authenticated)
2. Reviews and approves the requested permissions
3. Gets redirected to your `redirect_uri` with an authorization code

**Callback URL format:**

```
https://yourapp.com/callback?code=authorization_code&state=random_state_strin
```

{% endstep %}

{% step %}

#### Exchange code for tokens

Make a server-side POST request to the token endpoint:

```
POST https://www.make.com/oauth/v2/token
```

**Required Parameters:**

* `client_id`: Your Client ID
* `client_secret`: Your Client Secret
* `grant_type`: Set to `authorization_code`
* `code`: Authorization code from Step 2

**Response:**

```json
json{  "access_token": "eyJ...",  "refresh_token": "eyJ...",  "id_token": "eyJ...",  "token_type": "Bearer",  "expires_in": 3600}
```

{% endstep %}

{% step %}

#### Refresh access token

When the access token expires, use the refresh token:

```
POST https://www.make.com/oauth/v2/token
```

**Required parameters:**

* `client_id`: Your Client ID
* `client_secret`: Your Client Secret
* `grant_type`: Set to `refresh_token`
* `refresh_token`: Refresh token from Step 3
  {% endstep %}
  {% endstepper %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.make.com/api-documentation/authentication/oauth-flow/authorization-code-flow-with-refresh-token-confidential-clients.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
