Exchange the token for user information
When you request user information, API Yandex ID returns all the data that the OAuth token specified in the request grants access to.
The contents of the response depend on the app permissions that were selected during registration in Yandex OAuth. If multiple permissions are selected, the response is made up of the elements pertaining to each of these permissions.
Note
To send a request to API Yandex ID, you can use an OAuth token with permissions to access any of the Yandex services. However, only tokens with permissions from the API Yandex ID section set during app registration provide extended access to user data.
Request format
A request for information about a Yandex user is formed like this:
GET https://login.yandex.ru/info?
[& format=json | xml | jwt]
[& jwt_secret=<secret key>]
Authorization: OAuth <OAuth token>
GET https://login.yandex.ru/info?
& oauth_token=<OAuth token>
[& format=json | xml | jwt]
[& jwt_secret=<secret key>]
Alert
When this method is used, the OAuth token is passed in a parameter of a GET request and may remain publicly available in the browser history or in access logs of any intermediate host. An attacker may exploit such a token.
Request parameters
Parameter |
Value |
Description |
|
|
The OAuth token allowing to access the user's account data via API Yandex ID. The contents of the response depend on the permissions that are granted by the OAuth token specified in the request. The OAuth token must be included in the request in one of these two ways:
|
|
xml | json | jwt |
The format in which data should be returned. Possible values:
|
|
|
The secret to sign the JWT with. If this parameter isn't passed, the |
Response format
The response contains a set of standard and additional fields depending on the app permissions.
The response body is in JSON format by default. To get a response in XML or JWT format, include the format
parameter with the xml
or jwt
value in the request:
- An XML response has the same structure as a JSON response. Data is wrapped in a root
<user>
tag. - A JWT response always includes a standard set of fields. Depending on the selected permissions, additional fields may also be returned.
Standard response parameters
The response to a request for user information contains the fields listed below:
Property |
Description |
|
Yandex username. |
|
Unique Yandex user ID. |
|
ID of the app for which the OAuth token passed in the request was issued. Can be found in the app properties. To open them, select the app name. |
|
"id" equivalent. This field is only available in JWT format. |
|
Yandex ID of the logged in user. Generated by Yandex based on the |
Additional response parameters
Additional response fields depend on the permissions selected when registering the app in Yandex OAuth and provided by the OAuth token:
If multiple permissions are selected, the response is made up of the elements pertaining to each of these permissions.
No permissions from the section API Yandex ID
A request to API Yandex ID can use an OAuth token that was issued for a different Yandex service. If the token is valid, the API returns the following response:
{
"login": "ivan",
"id": "1000034426",
"client_id": "4760187d81bc4b7799476b42b5103713",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
<?xml version="1.0" encoding="utf-8"?>
<user>
<login>ivan</login>
<id>1000034426</id>
<client_id>4760187d81bc4b7799476b42b5103713</client_id>
<psuid>1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge</psuid>
</user>
{
"iat": 1620915565,
"jti": "384b6169-b3f6-11eb-a7cd-0c42a10aa38c",
"exp": 1652451414,
"iss": "login.yandex.ru",
"uid": 1000034426,
"login": "ivan",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
The response contains a standard set of fields.
Access to the email address
For a request with an OAuth token that has the Email address permission, the API returns the following response:
{
"login": "ivan",
"old_social_login": "uid-mmzxrnry",
"default_email": "test@yandex.ru",
"id": "1000034426",
"client_id": "4760187d81bc4b7799476b42b5103713",
"emails": [
"test@yandex.ru",
"other-test@yandex.ru"
],
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
<?xml version="1.0" encoding="utf-8"?>
<user>
<login>ivan</login>
<old_social_login>uid-mmzxrnry</old_social_login>
<default_email>test@yandex.ru</default_email>
<id>1000034426</id>
<client_id>4760187d81bc4b7799476b42b5103713</client_id>
<emails>
<address>test@yandex.ru</address>
<address>other-test@yandex.ru</address>
</emails>
<psuid>1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge</psuid>
</user>
{
"iat": 1620915565,
"jti": "384b6169-b3f6-11eb-a7cd-0c42a10aa38c",
"exp": 1652451414,
"iss": "login.yandex.ru",
"uid": 1000034426,
"login": "ivan",
"email": "test@yandex.ru",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
The response contains a standard set of fields and additional parameters:
Property |
Description |
|
Array of the user's email addresses. This currently includes only one address, which is the default email address. |
|
Default email address for contacting the user. |
|
default_email equivalent. This field is only available in JWT format. |
Access to the user avatar
For a request with an OAuth token that has the User avatar permission, the API returns the following response:
{
"login": "ivan",
"old_social_login": "uid-mmzxrnry",
"id": "1000034426",
"client_id": "4760187d81bc4b7799476b42b5103713",
"is_avatar_empty": false,
"default_avatar_id": "131652443",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
<?xml version="1.0" encoding="utf-8"?>
<user>
<login>zamulla.aleksey</login>
<old_social_login>uid-mmzxrnry</old_social_login>
<id>31652443</id>
<client_id>4760187d81bc4b7799476b42b5103713</client_id>
<is_avatar_empty>False</is_avatar_empty>
<default_avatar_id>31652443</default_avatar_id>
<psuid>1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge</psuid>
</user>
{
"iat": 1620915565,
"jti": "384b6169-b3f6-11eb-a7cd-0c42a10aa38c",
"exp": 1652451414,
"iss": "login.yandex.ru",
"uid": 1000034426,
"login": "ivan",
"avatar_id": "131652443",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
The response contains a standard set of fields and additional parameters:
Property |
Description |
|
Flag indicating whether the |
|
ID of the Yandex user's avatar.
If a picture with the passed ID doesn't exist, it links to the generic picture in the specified size. Available sizesTo get an image of the desired size, Yandex tries to locate a face in the avatar and crops the image to that area. Values that can be set in the picture URL:
|
|
default_avatar_id equivalent. This field is only available in JWT format. |
Access to the date of birth
For a request with an OAuth token that has the Date of birth permission, the API returns the following response:
{
"login": "ivan",
"old_social_login": "uid-mmzxrnry",
"birthday": "1987-03-12",
"id": "1000034426",
"client_id": "4760187d81bc4b7799476b42b5103713",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
<?xml version="1.0" encoding="utf-8"?>
<user>
<login>ivan</login>
<old_social_login>uid-mmzxrnry</old_social_login>
<birthday>1987-03-12</birthday>
<id>1000034426</id>
<client_id>4760187d81bc4b7799476b42b5103713</client_id>
<psuid>1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge</psuid>
</user>
{
"iat": 1620915565,
"jti": "384b6169-b3f6-11eb-a7cd-0c42a10aa38c",
"exp": 1652451414,
"iss": "login.yandex.ru",
"uid": 1000034426,
"login": "ivan",
"birthday": "1987-03-12",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
The response contains a standard set of fields and an additional parameter:
Property |
Description |
|
User's date of birth, in the format YYYY-MM-DD. Unknown parts of the date are filled in with zeros, for example: If the user's date of birth is unknown:
|
Access to the username, first name, last name, and gender
For a request with an OAuth token that has the Username, first name, last name, and gender permission, the API returns the following response:
{
"first_name": "Ivan",
"last_name": "Ivanov",
"display_name": "Ivan",
"real_name": "Ivan Ivanov",
"login": "ivan",
"old_social_login": "uid-mmzxrnry",
"sex": "male",
"id": "1000034426",
"client_id": "4760187d81bc4b7799476b42b5103713",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
<?xml version="1.0" encoding="utf-8"?>
<user>
<first_name>Ivan</first_name>
<last_name></last_name>
<display_name>Ivan</display_name>
<real_name>Ivan Ivanov</real_name>
<login>ivan</login>
<old_social_login>uid-mmzxrnry</old_social_login>
<sex>male</sex>
<id>1000034426</id>
<client_id>4760187d81bc4b7799476b42b5103713</client_id>
<psuid>1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge</psuid>
</user>
{
"iat": 1620915565,
"jti": "384b6169-b3f6-11eb-a7cd-0c42a10aa38c",
"exp": 1652451414,
"iss": "login.yandex.ru",
"login": "ivan",
"uid": 1000034426,
"display_name": "Ivan",
"name": "Ivan Ivanov",
"gender": "male",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
The response contains a standard set of fields and additional parameters:
Property |
Description |
|
First name that the user set in Yandex ID. |
|
Last name that the user set in Yandex ID. |
|
Name that's displayed for this account in the Yandex interface. |
|
First and last name that the user set in Yandex ID. |
|
User's gender. Possible values:
|
|
sex equivalent. This field is only available in JWT format. |
Access to the phone number
For a request with an OAuth token that has the Phone number permission, the API returns the following response:
{
"login": "ivan",
"id": "1000034426",
"client_id": "4760187d81bc4b7799476b42b5103713",
"default_phone": {
"id": 12345678,
"number": "+79037659418"
},
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
<?xml version="1.0" encoding="utf-8"?>
<user>
<login>ivan</login>
<id>1000034426</id>
<client_id>4760187d81bc4b7799476b42b5103713</id>
<psuid>1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge</psuid>
<default_phone>
<id>12345678</id>
<number>+79037659418</number>
</default_phone>
</user>
{
"iat": 1620915565,
"jti": "384b6169-b3f6-11eb-a7cd-0c42a10aa38c",
"exp": 1652451414,
"iss": "login.yandex.ru",
"uid": 1000034426,
"login": "ivan",
"number": "+79037659418",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
The response contains a standard set of fields and additional parameters:
Property |
Description |
|
Default phone number for contacting the user. This field contains the following parameters:
|
Example
If the app has an OAuth token that grants it all the API Yandex ID permissions, the response contains all the standard and additional parameters:
{
"first_name": "Ivan",
"last_name": "Ivanov",
"display_name": "ivan",
"emails": [
"test@yandex.ru",
"other-test@yandex.ru"
],
"default_email": "test@yandex.ru",
"default_phone": {
"id": 12345678,
"number": "+79037659418"
},
"real_name": "Ivan Ivanov",
"is_avatar_empty": false,
"birthday": "1987-03-12",
"default_avatar_id": "131652443",
"login": "ivan",
"old_social_login": "uid-mmzxrnry",
"sex": "male",
"id": "1000034426",
"client_id": "4760187d81bc4b7799476b42b5103713",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}
<?xml version="1.0" encoding="utf-8"?>
<user>
<first_name>Ivan</first_name>
<last_name>Ivanov</last_name>
<display_name>ivan</display_name>
<emails>
<address>test@yandex.ru</address>
<address>other-test@yandex.ru</address>
</emails>
<default_email>test@yandex.ru</default_email>
<default_phone>
<id>12345678</id>
<number>+79037659418</number>
</default_phone>
<real_name>Ivan Ivanov</real_name>
<is_avatar_empty>False</is_avatar_empty>
<birthday>1987-03-12</birthday>
<default_avatar_id>131652443</default_avatar_id>
<login>ivan</login>
<old_social_login>uid-mmzxrnry</old_social_login>
<sex>male</sex>
<id>1000034426</id>
<client_id>4760187d81bc4b7799476b42b5103713</client_id>
<psuid>1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge</psuid>
</user>
{
"iat": 1620915565,
"jti": "384b6169-b3f6-11eb-a7cd-0c42a10aa38c",
"exp": 1652451414,
"iss": "login.yandex.ru",
"uid": 1000034426,
"login": "ivan",
"avatar_id": "131652443",
"email": "test@yandex.ru",
"number": "+79037659418",
"display_name": "ivan",
"name": "Ivan Ivanov",
"gender": "male",
"psuid": "1.AAceCw.tbHgw5DtJ9_zeqPrk-Ba2w.qPWSRC5v2t2IaksPJgnge"
}