Tried token authentication today and found those small errors. If it really should have ben JWT and you are using djangorestframework-simplejwt then the action should look more like this:

action = ['auth', 'token', 'obtain', 'create']
This commit is contained in:
Jochen Wersdörfer 2018-04-19 15:30:39 +02:00
parent 8c47a875ec
commit 83cbff3331

View File

@ -269,12 +269,12 @@ For example, using the "Django REST framework JWT" package
client = coreapi.Client()
schema = client.get('https://api.example.org/')
action = ['api-token-auth', 'obtain-token']
params = {username: "example", email: "example@example.com"}
action = ['api-token-auth', 'create']
params = {"username": "example", "password": "secret"}
result = client.action(schema, action, params)
auth = coreapi.auth.TokenAuthentication(
scheme='JWT',
scheme='Token',
token=result['token']
)
client = coreapi.Client(auth=auth)