Utilizador — Chave API¶
As Chaves API são tokens de autenticação alternativos para utilização da API máquina-a-máquina.
Endpoints¶
| Método | URL |
|---|---|
GET |
/user/<user>/api_key/<api_key> |
POST |
/user/<user>/api_key |
PUT |
/user/<user>/api_key/<api_key> |
DELETE |
/user/<user>/api_key/<api_key> |
GET /user/<user>/api_key/<api_key>¶
Payload: Sem payload.
Devolve: A chave API.
Example:
curl -u "username:api_key" -H "Accept: application/json" \
https://app.duo.pt/user/{user_id}/api_key/{key_id}
Response:
{
"success": true,
"data": {
"api_key": {
"id": 1,
"name": "Example...",
"owner": 1,
"allowed_ips": ""
}
}
}
POST /user/<user>/api_key¶
| Parâmetro | Tipo | Descrição |
|---|---|---|
name |
string | Nome da chave |
allowed_ips |
string | Intervalos IP CIDR separados por vírgula ou espaço autorizados a utilizar esta chave. Vazio = qualquer IP. |
Devolve: A nova chave API.
Example:
curl -u "username:api_key" -H "Accept: application/json" \
-d "name=My+Key&allowed_ips=" \
https://app.duo.pt/user/{user_id}/api_key
Response:
{
"success": true,
"data": {
"api_key": {
"id": 1,
"name": "Example...",
"owner": 1,
"allowed_ips": "",
"unhashed_password": "T0qQ1MEJrhWIfi5kJJfF7dRd1vUKrKx6lH9VQtEsHJbGQPwh"
}
}
}
PUT /user/<user>/api_key/<api_key>¶
Mesmo payload que o POST.
Devolve: A chave API editada.
Example:
curl -u "username:api_key" -H "Accept: application/json" -X PUT \
-d "name=Updated+Key&allowed_ips=192.168.1.0/24" \
https://app.duo.pt/user/{user_id}/api_key/{key_id}
Response:
{
"success": true,
"data": {
"immutable": "hash",
"api_key": {
"id": 1,
"name": "Example...",
"owner": 1,
"allowed_ips": ""
}
}
}
DELETE /user/<user>/api_key/<api_key>¶
Payload: Sem payload.
Devolve: A chave API eliminada.
Example:
curl -u "username:api_key" -H "Accept: application/json" -X DELETE \
https://app.duo.pt/user/{user_id}/api_key/{key_id}
Response: