sleepytaco / UnTube

A simple, comprehensive YouTube playlist manager web app powered by YouTube Data API V3. Built with ❤ using Django, htmx and Bootstrap.
51 stars 3 forks source link

medium article is deleted and Site matching query does not exist. #47

Open phanirithvij opened 10 months ago

phanirithvij commented 10 months ago

The llink you posted on the readme in the running locally instructions https://dev.to/mdrhmn/django-google-authentication-using-django-allauth-18f8 is dead.

Also after I copied the cilent id and secret (I added the uris) I get this error when I try to login to google

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/google/login/

Django Version: 4.2.1
Python Version: 3.11.6
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'django.contrib.sites',
 'crispy_forms',
 'import_export',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'allauth.socialaccount.providers.google',
 'backend.users.apps.UsersConfig',
 'backend.main.apps.MainConfig',
 'backend.manage_playlists.apps.ManagePlaylistsConfig',
 'backend.charts.apps.ChartsConfig',
 'backend.search.apps.SearchConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last):
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/allauth/socialaccount/providers/oauth2/views.py", line 80, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/allauth/socialaccount/providers/base/mixins.py", line 18, in dispatch
    return self.login(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/allauth/socialaccount/providers/oauth2/views.py", line 108, in login
    app = provider.get_app(self.request)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/allauth/socialaccount/providers/base/provider.py", line 30, in get_app
    return adapter.get_app(request, self.id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/allauth/socialaccount/adapter.py", line 204, in get_app
    app = SocialApp.objects.get_current(provider, request)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/allauth/socialaccount/models.py", line 31, in get_current
    site = get_current_site(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/django/contrib/sites/shortcuts.py", line 16, in get_current_site
    return Site.objects.get_current(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/django/contrib/sites/models.py", line 59, in get_current
    return self._get_site_by_id(site_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/django/contrib/sites/models.py", line 30, in _get_site_by_id
    site = self.get(pk=site_id)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rithvij/.cache/pypoetry/virtualenvs/untube-7IRFPE0Q-py3.11/lib/python3.11/site-packages/django/db/models/query.py", line 637, in get
    raise self.model.DoesNotExist(
    ^

Exception Type: DoesNotExist at /accounts/google/login/
Exception Value: Site matching query does not exist.
phanirithvij commented 10 months ago

I removed the db and changed the site_id to something else and I ran make update and make run-server again and this issue disappeared but the SocialApp matching query does not exist. issue is there no matter how many times I increment the SITE_ID, what is this SocialApp concept in django-allauth I don't get it, should I change the example.com domain?

I get Creating Google social app... in the logs on the first visit to the site and there is no Social app created successfully or an error occurred line after that, how am I supposed to do parse this.