mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
335cfcde57
At present, a mix of link types are used in the Netbox documentation from markdown file links to relative and absolute anchor links. Of the three types, linking to markdown files is the most ideal because it allows navigation locally on disk, as well as being translated into working links at render time. While not obvious, mkdocs handles converting markdown links to valid URLs. Signed-Off-by: Marcus Crane <marcu.crane@daimler.com>
31 lines
1.0 KiB
Markdown
31 lines
1.0 KiB
Markdown
# REST API Authentication
|
|
|
|
The NetBox REST API primarily employs token-based authentication. For convenience, cookie-based authentication can also be used when navigating the browsable API.
|
|
|
|
{!docs/models/users/token.md!}
|
|
|
|
## Authenticating to the API
|
|
|
|
An authentication token is attached to a request by setting the `Authorization` header to the string `Token` followed by a space and the user's token:
|
|
|
|
```
|
|
$ curl -H "Authorization: Token $TOKEN" \
|
|
-H "Accept: application/json; indent=4" \
|
|
http://netbox/api/dcim/sites/
|
|
{
|
|
"count": 10,
|
|
"next": null,
|
|
"previous": null,
|
|
"results": [...]
|
|
}
|
|
```
|
|
|
|
A token is not required for read-only operations which have been exempted from permissions enforcement (using the [`EXEMPT_VIEW_PERMISSIONS`](../configuration/optional-settings.md#exempt_view_permissions) configuration parameter). However, if a token _is_ required but not present in a request, the API will return a 403 (Forbidden) response:
|
|
|
|
```
|
|
$ curl http://netbox/api/dcim/sites/
|
|
{
|
|
"detail": "Authentication credentials were not provided."
|
|
}
|
|
```
|