DRF & React: "login with google" не создает ни одного социального аккаунта в базе данных
Я не знаю, что я делаю. Я пытаюсь Login with Google из приложения React. Поэтому я создал проект в Google cloud platform, установил Authorized JavaScript origins url: http://localhost:3000
и Authorized redirect URIs http://127.0.0.1:8000/accounts/google/login/callback/
и получил Clint Id и Secret key. Затем я создал Социальное приложение из Django Admin сайта с этими ID и ключом.
тогда я пишу такой код:
settings.py:
INSTALLED_APPS = [
'myapp',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'corsheaders',
'rest_framework.authtoken',
'rest_auth',
'rest_auth.registration',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google', #google
]
SITE_ID = 1
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
],
'DEFAULT_FILTER_BACKENDS':['django_filters.rest_framework.DjangoFilterBackend'],
}
urls.py:
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('myapp.urls')),
path('api/rest-auth/', include('rest_auth.urls')),
path('api/rest-auth/registration/', include('rest_auth.registration.urls')),
path('accounts/', include('allauth.urls')),
в Reactjs:
//...code
responseGoogle = (response) => {
console.log(response);
}
//..code
<GoogleLogin
clientId="634453711672-3lf3sk6g4dl74q428n14jc4n6n592d99.apps.googleusercontent.com"
buttonText="Login"
onSuccess={this.responseGoogle}
onFailure={this.responseGoogle}
cookiePolicy={'single_host_origin'}
/>
когда я нажимаю эту кнопку Login, затем выбираю свой аккаунт gmail, в консоли появляется объект.
kx{Os: mx {$R: "**************", Ne: "Asif Biswas", ET: "Asif", GR: "Biswas",....}...}
.
но не создает ни одного социального аккаунта в базе данных.
Моя цель: нажать кнопку Login > аутентифицировать пользователя (установить token в локальном хранилище) > создать социальный аккаунт и токен приложения (в базе данных).
любое предложение?