Authentication Token Issue EVE
Hi I am using the eve token authentication (http://python-eve.org/tutorials/account_management.html#accounts-with-token-authentication) but am stuck with a 401 message. class Rol
Solution 1:
You have to encode in base64 you token before send it and in mongodb not encoded.
When Eve recived the token its decoded and then compare it with the db.
if you send:
curl -X "GET" "http://api.domain.com:5000/people/obama" -H "Authorization: Basic dGVzdDoxMjM0"
In the db has to be stored:
"token" : "1234",
Moreover you have to encoded token + : For example if your token value in db is "1234" you have to encode and send "1234:"
Solution 2:
There a few things wrong with your code:
- You are sending username and password with you Authorization header while your
RolesAuth
class is performing lookups ontoken
. Try passing an encoded token instead. - You stored the base64 encoded token in Mongo but you probably want to store the clean token instead, as the
check_auth
method will receive a decoded value astoken
argument (or you have to encode it again before performing the lookup). - You really really don't want to store the clean password in the database. These should be hashed/salted.
Post a Comment for "Authentication Token Issue EVE"