---
title: "Generate access token"
url: "https://docs.signnow.com/docs/oauth2/operations/post__oauth2_token"
type: "endpoint"
section: "oauth2"
slug: "oauth2/operations/post__oauth2_token"
method: "POST"
path: "/oauth2/token"
operation_id: "post__oauth2_token"
authorization: "basic"
---

# Generate access token

`POST /oauth2/token`

This endpoint generates an access token for a user.

In the request, specify the `grant_type` to use:

- `password`: generate an access token using the [password grant](/docs/authentication#password-grant).

- `refresh_token`: generate an access token using the [refresh token grant](/docs/authentication#refresh-token-grant).

- `authorization_code`: generate an access token using the [authorization code grant](/docs/authentication#authorization-code-grant).

See also: [Authentication](/docs/authentication#about-authentication).

## Authorization

basic

## Form Data Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `username` | string | Yes | User email. Required if `grant_type`: `password`. |
| `password` | string | Yes | User password. Required if `grant_type`: `password`. |
| `grant_type` | string | Yes | Specifies the grant type for authorization. Possible values: `password`, `refresh_token`, `authorization_code`. |
| `scope` | string | No | Permissions for the issued token; `*` grants all permissions. Using scope, you can define a custom list of accessible URLs.  For example: `document/* GET/user` will allow access to:  1) all routes starting with `/document/` 2) `GET /user` route |
| `refresh_token` | string | No | The refresh token value, obtained from the `Generate access token` response. Required if `grant_type`: `refresh_token`. |
| `code` | string | No | The authorization code, obtained from the [Get authorization code](/docs/oauth2/operations/get-oauth2-userauth) response. Required if `grant_type`: `authorization_code`. |
| `expiration_time` | integer | No | Time until the token expires in seconds. Default value is 2592000  seconds (30 days). |

## Responses

### 200

Returns an `access_token` for the user, along with its type, scope, expiration time, and `refresh_token`.

**Example** (`application/json`)

```json
{
  "scope": "*",
  "expires_in": 2592000,
  "last_login": 1,
  "token_type": "bearer",
  "access_token": "7cXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "refresh_token": "59XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
```

### 400

* The basic authorization token is incorrect.
* A required parameter is missing.
* The scope is incorrect.
* The password or email is incorrect.
* The `expiration_time` parameter must be greater than 0.
* The user is permanently banned.
* The user is temporarily banned.
* The user is subject to SSO rules or added to an organization.
* The user’s email is not verified.
* Refresh token is incorrect.

**Example** (`Example 1`)

```json
{
  "code": 1538,
  "error": "invalid_client"
}
```

**Example** (`Unverified email`)

```json
{
  "code": 1545,
  "error": "unverified_email"
}
```

**Example** (`Scope is incorrect`)

```json
{
  "error": "invalid_scope."
}
```

**Example** (`Refresh token incorrect`)

```json
{
  "code": 997,
  "error": "Invalid refresh token. Please log out and log back in again."
}
```

**Example** (`User is permanently banned`)

```json
{
  "code": 65681,
  "error": "This account has been deactivated permanently. Please contact SignNow Customer Service to reactivate your account."
}
```

**Example** (`User is temporarily banned`)

```json
{
  "code": 65681,
  "error": "This account has been deactivated temporarily for %N% minutes. To reactivate the account sooner, please contact SignNow Customer Service."
}
```

**Example** (`expiration_time is incorrect`)

```json
{
  "error": "The `expiration_time` parameter must be greater than 0."
}
```

**Example** (`Required parameter is missing`)

```json
{
  "error": "invalid_request."
}
```

**Example** (`Password or email is incorrect`)

```json
{
  "code": 826,
  "error": "Invalid credentials."
}
```

**Example** (`Basic authorization token is incorrect`)

```json
{
  "error": "invalid_client."
}
```

**Example** (`User is restricted by SSO or organization`)

```json
{
  "error": "Please use your corporate login page to login to SignNow."
}
```

### 403

User is not the application owner.

**Example** (`Example 1`)

```json
{
  "errors": [
    {
      "code": 11005001,
      "message": "Access denied."
    }
  ]
}
```

**Example** (`User not an owner`)

```json
{
  "errors": [
    {
      "code": 11005001,
      "message": "Access denied."
    }
  ]
}
```

## Code Examples

> Replace `$SIGNNOW_ACCESS_TOKEN` and any `{placeholder}` values before running.

### cURL

```bash
curl -X POST \
  "https://api.signnow.com/oauth2/token" \
  -H "Authorization: Basic $SIGNNOW_ACCESS_TOKEN" \
  -H "Content-Type: application/json"
```

---
*Full reference: https://docs.signnow.com/docs/oauth2/operations/post__oauth2_token*
