Bloquear usuários
Use a API REST para gerenciar usuários bloqueados.
Sobre o bloqueio de usuários
Se uma URL de solicitação não incluir um parâmetro {username}
, a resposta será para o usuário conectado (e você precisará transmitir as informações de autenticação com a solicitação). Informações particulares adicionais, como se um usuário tem a autenticação de dois fatores habilitada, são incluídas quando autenticado por meio do OAuth com o escopo user
.
List users blocked by the authenticated user
List the users you've blocked on your personal account.
Parâmetros para "List users blocked by the authenticated user"
Cabeçalhos |
---|
Nome, Tipo, Descrição |
accept string Setting to |
Parâmetros de consulta |
Nome, Tipo, Descrição |
per_page integer The number of results per page (max 100). Padrão: |
page integer Page number of the results to fetch. Padrão: |
Códigos de status de resposta HTTP para "List users blocked by the authenticated user"
Código de status | Descrição |
---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Exemplos de código para "List users blocked by the authenticated user"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/user/blocks
Response
Status: 200
[
{
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}
]
Check if a user is blocked by the authenticated user
Parâmetros para "Check if a user is blocked by the authenticated user"
Cabeçalhos |
---|
Nome, Tipo, Descrição |
accept string Setting to |
Parâmetros de caminho |
Nome, Tipo, Descrição |
username string ObrigatórioThe handle for the GitHub user account. |
Códigos de status de resposta HTTP para "Check if a user is blocked by the authenticated user"
Código de status | Descrição |
---|---|
204 | If the user is blocked |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
404 | If the user is not blocked |
Exemplos de código para "Check if a user is blocked by the authenticated user"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/user/blocks/USERNAME
If the user is blocked
Status: 204
Block a user
Parâmetros para "Block a user"
Cabeçalhos |
---|
Nome, Tipo, Descrição |
accept string Setting to |
Parâmetros de caminho |
Nome, Tipo, Descrição |
username string ObrigatórioThe handle for the GitHub user account. |
Códigos de status de resposta HTTP para "Block a user"
Código de status | Descrição |
---|---|
204 | No Content |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
Exemplos de código para "Block a user"
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/user/blocks/USERNAME
Response
Status: 204
Unblock a user
Parâmetros para "Unblock a user"
Cabeçalhos |
---|
Nome, Tipo, Descrição |
accept string Setting to |
Parâmetros de caminho |
Nome, Tipo, Descrição |
username string ObrigatórioThe handle for the GitHub user account. |
Códigos de status de resposta HTTP para "Unblock a user"
Código de status | Descrição |
---|---|
204 | No Content |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
Exemplos de código para "Unblock a user"
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/user/blocks/USERNAME
Response
Status: 204