django-rest-auth

My 'access_token' from facebook is “incorrect value”

雨燕双飞 提交于 2019-12-05 18:43:33
I'm using django-rest-auth which is "API extension for Django all-auth". I'm building a mobile app which can signup/login using Facebook token (url: http://localhost:8000/rest-auth/facebook/ ). get Facebook token using 'expo' export const doFacebookLogin = () => async dispatch => { let { type, token } = await Facebook.logInWithReadPermissionsAsync('194632xxxxxx', { permissions: ['public_profile'] }); if (type === 'cancel') { return dispatch({ type: FACEBOOK_LOGIN_CANCEL }) } doSocialAuthLogin(dispatch, token); }; Include token in Http POST request const doSocialAuthLogin = async (dispatch,

Django Rest Auth custom reset password confirm url

社会主义新天地 提交于 2019-12-05 08:12:37
问题 With django-rest-framework, when you post a reset password (rest-auth/password/reset/), there is an email send to the user email. This email contains a confirmation URL. I would like to change this url because I'm on a REST app case, I want this email to point on my frontend instead of the django backend. With the confirmation email case, I had to override get_email_confirmation_url method from the AccountAdapter . But with the reset password case, I have no clue how to do it (there is no

Django, Angular, & DRF: Authentication to Django backend vs. API

拟墨画扇 提交于 2019-12-04 08:30:28
I'm building an app with a Django backend, Angular frontend, and a REST API using Django REST Framework for Angular to consume. When I was still working out backend stuff with a vanilla frontend, I used the provided Django authentication to handle user auth- but now that I'm creating a REST based app, I'm not sure how to approach authentication. Since all user data will be either retrieved or submitted via the API, should API authentication be enough? If so, do I need to remove the existing Django authentication middleware? Right now, when I try to hit API endpoints on an early version of the

How can i make django-rest-framework-jwt return token on registration?

老子叫甜甜 提交于 2019-12-04 07:55:32
问题 I have a basic django rest service, which registers a person and updates his password. I want to add jwt authentication on top of it. If I follow the tutorial I would need to add a new url named "api-token-auth" in project's urls.py. But, I don't want to add this new url and want my register call to send a token in response. Here's my code: serializers.py class UserSerializer(serializers.HyperlinkedModelSerializer): def create(self, validated_data): user = User( username=validated_data[

How to override a form in django-rest-auth with my own custom form?

本小妞迷上赌 提交于 2019-12-04 05:16:28
问题 I'm using django-rest-auth and I am trying to fix a bug in the password reset view by overwriting one of the form's methods. Although I've successfully done something similar with a different django-rest-auth form, I can't make it work on this one. Whatever I do, the old form is used. api/urls.py from django.urls import include, path from django.contrib.auth import views from django.conf.urls import include, url from django.views.generic.base import RedirectView from .forms import

Django Rest Auth custom reset password confirm url

瘦欲@ 提交于 2019-12-03 20:41:11
With django-rest-framework, when you post a reset password (rest-auth/password/reset/), there is an email send to the user email. This email contains a confirmation URL. I would like to change this url because I'm on a REST app case, I want this email to point on my frontend instead of the django backend. With the confirmation email case, I had to override get_email_confirmation_url method from the AccountAdapter . But with the reset password case, I have no clue how to do it (there is no method in the adapter about reseting password). Any idea? I did it with templatetags: https://docs

Django rest registration

安稳与你 提交于 2019-12-03 20:20:42
I am using Django-rest-auth ( https://github.com/Tivix/django-rest-auth ) in my django project for login and registration. I see a default registration form as follows: Currently I am being able to register a new user with email instead of username. The default auth_user table in my MySql database has following columns: (id, password,last_login, is_superuser, username, first_name, last_name, email, is_staff, is_active, date_joined) My settings.py : INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib

How to save extra fields on registration using custom user model in DRF + django-rest-auth

限于喜欢 提交于 2019-12-03 08:58:21
Using Django REST Framework (DRF), with django-rest-auth, I created a custom user model with one extra field. My aim is to use the django-rest-auth registration endpoint to register a new user in one request, and thus sending all the data to create a new user, including the data for the extra field. I am using AbstractUser, since it seems recommended for beginners, where more advanced developers could use AbstractBaseUser. This is also why the following SO answers looks too complicated for what I want to achieve: link here . I know this question has been asked multiple times, but the answers

How to customize django rest auth password reset email content/template

梦想与她 提交于 2019-12-02 20:56:05
In django rest_auth password reset, default email content look like following:- You're receiving this email because you requested a password reset for your user account at localhost:8000. Please go to the following page and choose a new password: http://localhost:8000/api/reset/Kih/89a-23809182347689312b123/ Your username, in case you've forgotten: test Thanks for using our site! The localhost:8000 team How to customize content of this email ? You need to hook up your own reset password serializer ( PASSWORD_RESET_SERIALIZER ) with customized save method. (ref: https://github.com/Tivix/django

Modify response from Django REST API using CustomUserModel extending default User Model and API classes

天涯浪子 提交于 2019-12-02 06:46:25
I have a Django Project with CustomUserModel. I have extended Django default RegisterView with my CustomRegisterView, and also created CustomLoginView by extending LoginView. Everything works fine, data too get saved with custom fields, and while loging in and registering, I get a "key" in response, but I want to customize response of both the APIs with additional fields such as primary key value and a result_flag which will be either 0 or 1. My CustomRegisterSerializer class is defined as- class CustomRegisterSerializer(RegisterSerializer): email = serializers.EmailField() password1 =