Get an authentication token

Gets an authorization token. The format is OAuth 2.0. The token is included in the header of each request as Authorization: Bearer token.

Alert

The request body must be sent as a single line.

Request Example
curl -X 'POST' \
'{host}/security/oauth/token' \
-H 'accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'client_id=client_id&client_secret=client_secret&grant_type=client_credentials&scope=read%20write'

Request

POST

/security/oauth/token

Body

application/x-www-form-urlencoded
{
  "client_id": "123123123",
  "client_secret": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
  "grant_type": "client_credentials",
  "scope": "read write"
}

Name

Description

client_id

Type: string

client ID

Example: client_id

client_secret

Type: string

secret

Example: client_secret

grant_type

Type: string

Type of access

Default: client_credentials

scope

Type: string

Access rights

Default: read write

Responses

200 OK

Successful authentication

Body

application/json
{
  "access_token": "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
}

Name

Description

access_token

Type: string

Example: example

400 Bad Request

Error in the parameters, the response contains a list of validation errors

Body

application/json
[
  {
    "code": 100,
    "description": "Description of error"
  }
]

Type: ErrorItem[]

ErrorItem

Name

Description

code

Type: integer

Error code agreed with Yandex

description

Type: string

Error message

Example: Description of error

Example
{
  "code": 100,
  "description": "Description of error"
}

500 Internal Server Error

Internal server errors

Body

application/json
[
  {
    "code": 100,
    "description": "Description of error"
  }
]

Type: ErrorItem[]

Previous