Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: SocialApp matching query does not exist

I'm using django-allauth, and I configured localhost:9000/admin/ with the following details:

socialapp .
provider:
Name:
Client id:
App ID, or consumer key
Key:
Secret:  etc .

I set SITE_ID = 2 (because I changed the default site example.com to localhost:9000)

In settings.py:

   INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django.contrib.admin',
        'uni_form',
        'allauth',
        'allauth.account',
        'allauth.socialaccount',
        'bootstrapform',
        # 'allauth.socialaccount.providers.twitter',
        # 'allauth.socialaccount.providers.openid',
         'allauth.socialaccount.providers.facebook',
    )
    SOCIALACCOUNT_PROVIDERS = \
        { 'facebook':
            { 'SCOPE': ['email', 'publish_stream'],
              'AUTH_PARAMS': { 'auth_type': 'reauthenticate' },
              'METHOD': 'oauth2' ,
              'LOCALE_FUNC': 'path.to.callable'} }

When I go to:

http://localhost:9000/accounts/facebook/login

I get:

Error :  `SocialApp matching query does not exist.

What am I doing wrong?

like image 458
masterofdestiny Avatar asked Mar 14 '13 12:03

masterofdestiny


4 Answers

Using the Django admin you need to create a SocialApp listing your Facebook app credentials. Make sure that this app is attached to the proper site (as in, django.contrib.sites.models.Site).

In your case, there needs to be a django.contrib.sites.models.Site instance with id=2 (check the sites admin) that is listed as a site for the SocialApp.

If either the SocialApp is missing, or if it is created but not attached to a site matching your settings.SITE_ID, then allauth does not know what app to pick, resulting in the error message you listed above.

like image 93
pennersr Avatar answered Nov 16 '22 23:11

pennersr


For me, it showed this error when I had in settings.py:

SITE_ID = 1

It worked when I changed it to 2:

SITE_ID = 2
like image 34
subodhk Avatar answered Nov 17 '22 00:11

subodhk


In my case, on the Add social application page, I forgot to select my site as "Chosen sites" 🤦🏼‍♂️

See screenshot below (on the bottom right is the Chosen Sites list): enter image description here

like image 17
Deep Avatar answered Nov 16 '22 22:11

Deep


Step 1: Go to your admin page. Find social application

enter image description here

Step 2: now add the lines like the following image. Give your client id and secret key given by google api and move available site (example.com) to chosen sites enter image description here

Step 3: Now go to sites in the side navigation of admin page and customize like the following image and save it

enter image description here

Step 4: now, add, SITE_ID = 1 in settings.py file.

like image 15
Sayad Ahmed Shaurov Avatar answered Nov 16 '22 23:11

Sayad Ahmed Shaurov