Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
fw:djangorest [2014/06/02 19:06] alfred [Filtering works?] |
fw:djangorest [2020/05/09 09:25] (actual) |
||
|---|---|---|---|
| Línea 524: | Línea 524: | ||
| Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b | Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b | ||
| </code> | </code> | ||
| - | The curl command line tool may be useful for testing token authenticated APIs. For example: | + | The curl command for obtain the token: |
| + | <code> | ||
| + | curl -X POST http://127.0.0.1:8000/api-token-auth/ -H "Content-type: application/json" -d '{"username": "alfred", "password": "test"}' | ||
| + | </code> | ||
| + | |||
| + | The curl command for testing token authenticated APIs. For example: | ||
| <code> | <code> | ||
| curl -X GET http://127.0.0.1:8000/api/example/ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' | curl -X GET http://127.0.0.1:8000/api/example/ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' | ||
| Línea 571: | Línea 576: | ||
| return (user, None) | return (user, None) | ||
| </code> | </code> | ||
| - | |||
| ==== Permissions ==== | ==== Permissions ==== | ||
| Permissions are defined as a list of permission classes. When a view is called a permission list classes is checked, if any of them fails an ''exceptions.PermissionDenied'' exception will be raised. \\ | Permissions are defined as a list of permission classes. When a view is called a permission list classes is checked, if any of them fails an ''exceptions.PermissionDenied'' exception will be raised. \\ | ||