pennersr / django-allauth

Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.
https://allauth.org
MIT License
9.55k stars 3.04k forks source link

AssertionError at /es/accounts/google/login/callback/ No exception message supplied #2212

Closed beren5000 closed 4 years ago

beren5000 commented 5 years ago

greetings i had configured django allauth using, i had django tenant working in my project and everything was fine, i logged with my social accounts (facebook, google and twitter), and everything where smooth. but now i decided that django tenant wasnt the solution that i needed, i rearrange my project and delete everything that was related to django tenant, recreate the database and reconfigure my social accounts, but when i try to login i keep getting this error

AssertionError at /es/accounts/google/login/callback/ No exception message supplied

with this trace:

Internal Server Error: /es/accounts/google/login/callback/
Traceback (most recent call last):
  File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/allauth/socialaccount/providers/oauth2/views.py", line 73, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/allauth/socialaccount/providers/oauth2/views.py", line 143, in dispatch
    return complete_social_login(request, login)
  File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/allauth/socialaccount/helpers.py", line 153, in complete_social_login
    return _complete_social_login(request, sociallogin)
  File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/allauth/socialaccount/helpers.py", line 175, in _complete_social_login
    ret = _process_signup(request, sociallogin)
  File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/allauth/socialaccount/helpers.py", line 46, in _process_signup
    get_adapter(request).save_user(request, sociallogin, form=None)
  File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/allauth/socialaccount/adapter.py", line 81, in save_user
    sociallogin.save(request)
  File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/allauth/socialaccount/models.py", line 242, in save
    setup_user_email(request, user, self.email_addresses)
  File "/Applications/MAMP/htdocs/enviroment/kleanapp/lib/python3.7/site-packages/allauth/account/utils.py", line 254, in setup_user_email
    assert not EmailAddress.objects.filter(user=user).exists()
AssertionError
[22/Feb/2019 21:11:45] "GET /es/accounts/google/login/callback/?state=bCLR11RBMTUY&code=4/-QAzhTxuYiUr1iSB6o4by3t9gwtEMVRncbcRvJWTsgtFzJWzl5kw2BkMpSN3W-0p88UqsYzHXuKvLTlr5AZeDlE&scope=email%20profile%20https://www.googleapis.com/auth/userinfo.profile%20https://www.googleapis.com/auth/userinfo.email HTTP/1.1" 500 112632

i have not change nothing with my allauth configuration, everything is vanilla and was working in the same way as before, but i don't know what really happen

i found a similar issue in here:

1304

but im not using a custom signup and as i see, the user is created, the email and the social account for that user too, everything is fine, even if i try to login after the error appear, everything looks fine, the login is completed and i can use the site normally

those are my project settings related to allauth

ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = False
ACCOUNT_USER_MODEL_USERNAME_FIELD = None

SOCIALACCOUNT_PROVIDERS = {
'google': {
'SCOPE': [
'profile',
'email',
],
'AUTH_PARAMS': {
'access_type': 'online',
}
},
'twitter': {
'SCOPE': ['email'],
},
'facebook': {
'METHOD': 'oauth2',
'SCOPE': ['email', 'public_profile', 'user_friends'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'INIT_PARAMS': {'cookie': True},
'FIELDS': [
'id',
'email',
'name',
'first_name',
'last_name',
'verified',
'locale',
'timezone',
'link',
'gender',
'updated_time',
],
'EXCHANGE_TOKEN': True,
'LOCALE_FUNC': lambda request: 'en',
'VERIFIED_EMAIL': False,
}
}

AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',
# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
)
pennersr commented 4 years ago

https://django-allauth.readthedocs.io/en/latest/faq.html#why-did-you-just-close-my-issue

krishnarathore1234 commented 1 year ago

AssertionError at /accounts/google/login/callback/

No exception message supplied
Request Method: | GET -- | -- http://127.0.0.1:8000/accounts/google/login/callback/?state=6VKuyqVV5ulQousa&code=4%2F0Adeu5BUHoVDzqrKs2kHBiuzSbhZwqdd6ok1dVMNqY5oguAm1p5s4T039NseBLMtAcEglTQ&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+openid&authuser=1&prompt=consent 4.2.2 AssertionError /home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/allauth/socialaccount/helpers.py, line 191, in complete_social_login allauth.socialaccount.providers.oauth2.views.view /home/muddledluck/Desktop/new_studiofy/env/bin/python3 3.10.12 ['/home/muddledluck/Desktop/new_studiofy', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf'] Wed, 06 Sep 2023 07:08:28 +0000
  • /home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/allauth/socialaccount/helpers.py, line 191, in complete_social_login
    1.     assert not sociallogin.is_existing
  • AssertionError at /accounts/google/login/callback/ No exception message supplied Request Method: GET Request URL: http://127.0.0.1:8000/accounts/google/login/callback/?state=6VKuyqVV5ulQousa&code=4%2F0Adeu5BUHoVDzqrKs2kHBiuzSbhZwqdd6ok1dVMNqY5oguAm1p5s4T039NseBLMtAcEglTQ&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+openid&authuser=1&prompt=consent Django Version: 4.2.2 Exception Type: AssertionError Exception Location: /home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/allauth/socialaccount/helpers.py, line 191, in complete_social_login Raised during: allauth.socialaccount.providers.oauth2.views.view Python Executable: /home/muddledluck/Desktop/new_studiofy/env/bin/python3 Python Version: 3.10.12 Python Path: ['/home/muddledluck/Desktop/new_studiofy', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf', '/home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/odf'] Server time: Wed, 06 Sep 2023 07:08:28 +0000 Traceback [Switch to copy-and-paste view](http://127.0.0.1:8000/accounts/google/login/callback/?state=6VKuyqVV5ulQousa&code=4%2F0Adeu5BUHoVDzqrKs2kHBiuzSbhZwqdd6ok1dVMNqY5oguAm1p5s4T039NseBLMtAcEglTQ&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+openid&authuser=1&prompt=consent#) /home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/django/core/handlers/exception.py, line 42, in inner response = await get_response(request) … Local vars /home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/django/core/handlers/base.py, line 253, in _get_response_async response = await wrapped_callback( … Local vars /usr/lib/python3.10/concurrent/futures/thread.py, line 58, in run result = self.fn(*self.args, **self.kwargs) … Local vars /home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/allauth/socialaccount/providers/oauth2/views.py, line 86, in view return self.dispatch(request, *args, **kwargs) … Local vars /home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/allauth/socialaccount/providers/oauth2/views.py, line 163, in dispatch return complete_social_login(request, login) … Local vars /home/muddledluck/Desktop/new_studiofy/env/lib/python3.10/site-packages/allauth/socialaccount/helpers.py, line 191, in complete_social_login assert not sociallogin.is_existing How we solve this error in social django allauth so give me a valid code and we use latest version of django allauth so give me a usable code step by step
    NTN-code commented 11 months ago

    https://github.com/iMerica/dj-rest-auth/issues/551#issuecomment-1858911936