[Answered ]-Django Token on test case return an error 'Authentication credentials were not provided'

1👍

I think what you are missing is the following:

response = self.client.put('/api/v1/credit-card', {
    'exp_date': '02/2028',
    'holder': 'Olivia Johnson',
    'number': '1234567891231234',
    'cvv': '999'
}, headers=self.headers)

When you pass **self.headers you basically are passing the following:

self.client.put('/api/v1/credit-card', {
    'exp_date': '02/2028',
    'holder': 'Olivia Johnson',
    'number': '1234567891231234',
    'cvv': '999'
}, Autorization=value)

And because normally most of the functions in python accept a kwargs it will just leave headers=None and that’s why you are strugling with this…

Leave a comment