Thursday, April 30, 2015

Django oauth2 encrypt password

Hello,
I am following instructions under https://django-oauth-toolkit.readthedocs.org/en/latest/rest-framework/getting_started.html

I am having trouble with creating a user with encrypted password.

I am able to create a user with the call

curl -H "Authorization: Bearer lXbYKZqnPeqOyYaHyB3EOAvcMny13j" -X POST -d"username=foo1&password=bar1&first_name=foo1&email=foo1@screens.com" http://${endpoint}/users/

{"id":30,"password":"bar1","last_login":null,"is_superuser":false,"username":"foo1","first_name":"foo1","last_name":"","email":"foo1@screens.com","is_staff":false,"is_active":true,"date_joined":"2015-04-30T07:26:00.857445Z","groups":[],"user_permissions":[]}(env)

As you can see, it is creating a new user but the password is in clear text.

As a result, I am unable to get a user token

curl  -X POST -d "grant_type=password&username=foo1&password=bar1&scope=read" -u"${clientid}:${clientsecret}" http://${endpoint}/o/token/

{"error_description": "Invalid credentials given.", "error": "invalid_grant"}(env)

I sort of found a workaround. I can go in as admin to the console and change the user password manually. This seem to store the password as encrypted. How do I sole this via api calls?

I am sure I am missing something. Appreciate if someone could unblock me.

- Shekar

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7aead7cf-7aa1-49bd-877e-2ec41e48da8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment