Django Rest Framework & Vue.js; login via Google account; "User is already registered with this e-mail address."

Viewed 524

I have some trubbles with loggin to my web site via Google account. I created registarion via Google (using vue-google-login then sending that data to my backend to dj-rest-auth/google/) and thats work fine. But if I'm trying to log in user I get a response from my backend server "user is already registered with this email address". What can I do to make users sign in into my web app via Google account? How can I log in user but not register?

I would be grateful if somebody give answers because I loose too much time debuging and searching the answers. I'll put my code below. If you need more info - just let me know.

Thank you!

# authenticate.views
from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
from dj_rest_auth.registration.views import SocialLoginView

class GoogleLogin(SocialLoginView):
    adapter_class = GoogleOAuth2Adapter

#authenticate.urls
from django.urls import path
from . import views
urlpatterns = [
    path('google/', views.GoogleLogin.as_view(), name='google_login')
]
#backend_main.urls
from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url
from authentication.views import GoogleLogin

from backend_main.api_views import get_router_urls

urlpatterns = [
    path('admin/', admin.site.urls),
    path('hr-api/', include(get_router_urls())),
    path('demo-hr-api/', include('backend_main.urls')),
    path('accounts/', include('allauth.urls'), name='socialaccount_signup'),
    path('dj-rest-auth/', include('dj_rest_auth.urls')),
    path('dj-rest-auth/registration/', include('dj_rest_auth.registration.urls')),
    path('dj-rest-auth/google/', GoogleLogin.as_view(), name='google_login'),
]

enter image description here

enter image description here

0 Answers
Related