We've recently moved some of the REST API documentation. If you can't find what you're looking for, you might try the Actions REST API page.
Пользователи
Используйте REST API для приостановки и отмены добавления пользователей на предприятии.
Сведения об администрировании пользователей
Эти конечные точки доступны только администраторам сайта, прошедшим проверку подлинности . Обычные пользователи получат 403 ответ.
List public keys
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры запроса |
| Имя, Тип, Описание |
per_pageintegerThe number of results per page (max 100). Значение по умолчанию: |
pageintegerPage number of the results to fetch. Значение по умолчанию: |
directionstringThe direction to sort the results by. Значение по умолчанию: Может быть одним из: |
sortstringЗначение по умолчанию: Может быть одним из: |
sincestringOnly show public keys accessed after the given time. |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
200 | OK |
Примеры кода
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/admin/keysResponse
Status: 200[
{
"key": "2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234",
"id": 2,
"url": "https://api.github.com/user/keys/2",
"title": "ssh-rsa AAAAB3NzaC1yc2EAAA",
"created_at": "2020-06-11T21:31:57Z",
"verified": false,
"read_only": false,
"last_used": "2020-06-11T22:31:57Z",
"user_id": 1,
"repository_id": 2
},
{
"key": "9Og8iYjAyymI9LvABpJerYrMxURPc8r+dB7TJyvv1234",
"id": 3,
"url": "https://api.github.com/user/keys/2",
"title": "ssh-rsa AAAAB3NzaC1yc2EAAA",
"created_at": "2020-06-11T21:31:57Z",
"verified": false,
"read_only": false,
"last_used": "2020-06-11T22:31:57Z",
"user_id": 1,
"repository_id": 2
}
]Delete a public key
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
key_idsstringОбязательноThe unique identifier of the key. |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
204 | No Content |
Примеры кода
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/admin/keys/KEY_IDSResponse
Status: 204List personal access tokens
Lists personal access tokens for all users, including admin users.
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры запроса |
| Имя, Тип, Описание |
per_pageintegerThe number of results per page (max 100). Значение по умолчанию: |
pageintegerPage number of the results to fetch. Значение по умолчанию: |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
200 | OK |
Примеры кода
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/admin/tokensResponse
Status: 200[
{
"id": 1,
"url": "https://api.github.com/authorizations/1",
"scopes": [
"public_repo"
],
"token": "ghu_16C7e42F292c6912E7710c838347Ae178B4a",
"token_last_eight": "Ae178B4a",
"hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8",
"app": {
"url": "http://my-github-app.com",
"name": "my github app",
"client_id": "abcde12345fghij67890"
},
"note": "optional note",
"note_url": "http://optional/note/url",
"updated_at": "2011-09-06T20:39:23Z",
"created_at": "2011-09-06T17:26:27Z",
"expires_at": "2011-09-08T17:26:27Z",
"fingerprint": "jklmnop12345678"
}
]Delete a personal access token
Deletes a personal access token. Returns a 403 - Forbidden status when a personal access token is in use. For example, if you access this endpoint with the same personal access token that you are trying to delete, you will receive this error.
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
token_idintegerОбязательноThe unique identifier of the token. |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
204 | No Content |
Примеры кода
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/admin/tokens/TOKEN_IDResponse
Status: 204Delete a user
Deleting a user will delete all their repositories, gists, applications, and personal settings. Suspending a user is often a better option.
You can delete any user account except your own.
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
usernamestringОбязательноThe handle for the GitHub user account. |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
204 | No Content |
Примеры кода
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/admin/users/USERNAMEResponse
Status: 204Create an impersonation OAuth token
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
usernamestringОбязательноThe handle for the GitHub user account. |
| Параметры запроса |
| Имя, Тип, Описание |
scopesarray of stringsОбязательноA list of scopes. |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
200 | Response when getting an existing impersonation OAuth token |
201 | Response when creating a new impersonation OAuth token |
Примеры кода
curl \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/admin/users/USERNAME/authorizations \
-d '{"scopes":["public_repo"]}'Response when getting an existing impersonation OAuth token
Status: 200{
"id": 1,
"url": "https://api.github.com/authorizations/1",
"scopes": [
"public_repo"
],
"token": "ghu_16C7e42F292c6912E7710c838347Ae178B4a",
"token_last_eight": "Ae178B4a",
"hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8",
"app": {
"url": "http://my-github-app.com",
"name": "my github app",
"client_id": "abcde12345fghij67890"
},
"note": "optional note",
"note_url": "http://optional/note/url",
"updated_at": "2011-09-06T20:39:23Z",
"created_at": "2011-09-06T17:26:27Z",
"expires_at": "2011-10-06T17:26:27Z",
"fingerprint": ""
}Delete an impersonation OAuth token
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
usernamestringОбязательноThe handle for the GitHub user account. |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
204 | No Content |
Примеры кода
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/admin/users/USERNAME/authorizationsResponse
Status: 204Suspend a user
If your GitHub instance uses LDAP Sync with Active Directory LDAP servers, Active Directory LDAP-authenticated users cannot be suspended through this API. If you attempt to suspend an Active Directory LDAP-authenticated user through this API, it will return a 403 response.
You can suspend any user account except your own.
Note that, if you choose not to pass any parameters, you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
usernamestringОбязательноThe handle for the GitHub user account. |
| Параметры запроса |
| Имя, Тип, Описание |
reasonstringThe reason the user is being suspended. This message will be logged in the audit log. If you don't provide a |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
204 | No Content |
Примеры кода
curl \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/users/USERNAME/suspended \
-d '{"reason":"Suspended during leave of absence."}'Response
Status: 204Unsuspend a user
If your GitHub instance uses LDAP Sync with Active Directory LDAP servers, this API is disabled and will return a 403 response. Active Directory LDAP-authenticated users cannot be unsuspended using the API.
Параметры
| Заголовки |
|---|
| Имя, Тип, Описание |
acceptstringSetting to |
| Параметры пути |
| Имя, Тип, Описание |
usernamestringОбязательноThe handle for the GitHub user account. |
| Параметры запроса |
| Имя, Тип, Описание |
reasonstringThe reason the user is being unsuspended. This message will be logged in the audit log. If you don't provide a |
Коды состояния HTTP-ответа
| Код состояния | Описание |
|---|---|
204 | No Content |
Примеры кода
curl \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://HOSTNAME/api/v3/users/USERNAME/suspended \
-d '{"reason":"Unsuspended after leave of absence."}'Response
Status: 204