[Django]-Django: SocialApp matching query does not exist

80πŸ‘

βœ…

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.

πŸ‘€pennersr

19πŸ‘

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
πŸ‘€subodhk

19πŸ‘

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

πŸ‘€Deep

19πŸ‘

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.

4πŸ‘

As an alternative to putting that into the admin, you can also put it in your settings like so: (At least in 2022 with version django-allauth==0.45.0

SOCIALACCOUNT_PROVIDERS = {
    'discord': {
        # From https://developer.twitter.com
        'APP': {
            'client_id': os.environ['TWITTER_API_KEY'],
            'secret': os.environ['TWITTER_API_SECRET'],
            'key': os.environ['TWITTER_APP_ID'],
        }
    },
    'twitter': {
        # From https://developer.twitter.com
        'APP': {
            'client_id': os.environ['TWITTER_API_KEY'],
            'secret': os.environ['TWITTER_API_SECRET'],
            'key': os.environ['TWITTER_APP_ID'],
        }
    },
}

Documentation is at: https://django-allauth.readthedocs.io/en/latest/installation.html and https://django-allauth.readthedocs.io/en/latest/configuration.html

πŸ‘€boatcoder

1πŸ‘

It is possible that Django created an β€˜example.com’ site for you already (if it’s not a new project). So if this is the case you will need to delete that entry from the Sites admin page AND change the SITE_ID in settings.py to be the correct ID (probably 2 rather than 1).

Consider playing around with the SITE_ID value. For example: SITE_ID = 3, etc.

πŸ‘€Evans Kiptoo

1πŸ‘

FWIW, if configuration via the DB is giving you problems, note that you can also use configuration in settings:

SOCIALACCOUNT_PROVIDERS = {
"google": {
    "APP": {
        "client_id": os.environ[("GOOGLE_OAUTH_CLIENT_ID"],
        "secret": os.environ[("GOOGLE_OAUTH_SECRET"],
    },
},
}

@Penners

πŸ‘€Evans Kiptoo

0πŸ‘

This worked for me

    SOCIALACCOUNT_PROVIDERS = {
    'google': {
        'SCOPE' : [
            'profile',
            'email'
        ],
        'APP': {
            'client_id': os.environ['CLIENT_ID'],
            'secret': os.environ['CLIENT_SECRET'],
        },
        'AUTH_PARAMS': {
            'access_type':'online',
        }
    }
}
πŸ‘€Kelly Kiiru

Leave a comment