Closed DRG104 closed 2 years ago
headers: {
Authorization: Token ${user.token}
// default is 'Bearer', but that is for the express server: using django and it expects the authorization header to be Token 'user.token'
}
I don't understand, while I'm troubleshooting I am trying to use postman, if the default is bearer
then shouldn't the request go through in Postman? In any case, both from the admin view and postman do not allow the request to go through.
Solution:
In Authorization tab (where we traditionally set the bearer token such as in the pets API) set authorization to NO authorization then the next tab over click on headers and set the Key to Authroization
and Value Token <enter token here>
.
Also, to view the headers for use in the front end: Click on </>
then change the code snippet to Node.Js - Axios
and you can see headers here.
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
DR
What's the problem you're trying to solve?
Assigning token for credential usage (such as sign out, change password, etc)
Post any code you think might be relevant (one fenced block per file)
input
(in postman)output
Code in boilerplate:
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
"detail": "Authentication credentials were not provided."
What is your best guess as to the source of the problem?
The documentation provided in the repo makes reference to changing token type to
bearer
which I assume is what we are used to from previous projects. I noticed the token provided in the boilerplate is longer than the bearer tokens from before.What things have you already tried to solve the problem?
I attempted to change the class of token to follow the syntax in the documentation but I don't believe I'm accessing the token correctly. To begin with, the imports from the document don't match the imports of the boilerplate, specifically
rest_framework.authtoken.models.Token
. So I believe the boilerplate is handling authentication differently and I would rather try to understand how its working, rather than change it.Paste a link to your repository here https://github.com/Zene09/server-dreamlancer