0

I am using django allauth for authentication

this is my settings.py

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.TokenAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ],
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated'
    ],
}

the installed app are these:

'rest_framework',
'rest_framework.authtoken',
'rest_auth',
'rest_auth.registration',
'allauth',
'allauth.account',

and i am trying like way:

curl -X POST "http://127.0.0.1:8000/api/v1/cinema-hall/" -H 'Authorization: Token 44eba1cdb1ecde6d3a55d6c85d7c4f44315f2c44'

this error i am getting:

{"detail":"Authentication credentials were not provided."}

I see many similar post exist like this: Django Rest Framework Authentication credentials were not provided

but those are not solved my issue.

Can anyone tell me what is the possible reason of facing this error?

1 Answers1

0

I'm not very experienced with using CURL to test an api, but is it possible that 'Authorization' is misspelled as 'Authorizaion'?

Edit: after your response confirming that's not the case, I noticed that you have both TokenAuthentication and SessionAuthentication in the default authentication classes. Either remove SessionAuthentication or add the required credentials (cookie containing session details and csrf token).

dizzidude
  • 184
  • 2
  • 7
  • No, It's not misspillied in real curl. I have edited the post, pelase check –  Mar 17 '21 at 19:37