使用 CURL

如果針對此端點執行卷曲

curl http://localhost:8000/auth/    
op : {"detail": "Authentication credentials were not provided."}%

將返回 401 錯誤 UNAUTHORIZED

但是如果我們之前得到一個令牌:

curl -X POST -d "user=Pepe&password=aaaa"  http://localhost:8000/
{"token": "f7d6d027025c828b65cee5d38240aec60dffa150", "detail": "POST answer"}%

然後我們將該標記放入請求的標題中,如下所示:

curl http://localhost:8000/auth/ -H 'Authorization: Token f7d6d027025c828b65cee5d38240aec60dffa150'

op: {"detail": "I suppose you are authenticated"}%