Skip to main content

Authentication for facebook, linkedin and twitter

Project description

BaseApp Social Auth - Django

Usage

Use this package to login/signup using social networks (Facebook, Google and others)

Full documentation

Installation

Install the package

Add to requirements/base.txt:

baseapp-social-auth @ git+https://github.com/silverlogic/baseapp-backend.git@v0.1#subdirectory=baseapp-social-auth

Add to your routes

from baseapp_social_auth.views import SocialAuthViewSet  # noqa
router.register(r"social-auth", SocialAuthViewSet, basename="social-auth")

Add INSTALLED_APPS

INSTALLED_APPS = [
    ...
    "social_django",
    "rest_social_auth",
    "baseapp_social_auth.cache",
    ...
]

Add CELERY_BEAT_SCHEDULE

"clean-up-social-auth-cache": {
    "task": "baseapp_social_auth.cache.tasks.clean_up_social_auth_cache",
    "schedule": timedelta(hours=1),
    "options": {"expires": 60 * 30},
},

Add your settings

from baseapp_social_auth.settings import (  # noqa
    SOCIAL_AUTH_BEAT_SCHEDULES,
    SOCIAL_AUTH_FACEBOOK_KEY,
    SOCIAL_AUTH_FACEBOOK_PROFILE_EXTRA_PARAMS,
    SOCIAL_AUTH_FACEBOOK_SCOPE,
    SOCIAL_AUTH_FACEBOOK_SECRET,
    SOCIAL_AUTH_LINKEDIN_OAUTH2_FIELD_SELECTORS,
    SOCIAL_AUTH_LINKEDIN_OAUTH2_KEY,
    SOCIAL_AUTH_LINKEDIN_OAUTH2_SCOPE,
    SOCIAL_AUTH_LINKEDIN_OAUTH2_SECRET,
    SOCIAL_AUTH_GOOGLE_OAUTH2_KEY,
    SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET,
    SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE,
    SOCIAL_AUTH_GOOGLE_OAUTH2_AUTH_EXTRA_ARGUMENTS,
    SOCIAL_AUTH_TWITTER_KEY,
    SOCIAL_AUTH_TWITTER_SECRET,
    SOCIAL_AUTH_PIPELINE,
    SOCIAL_AUTH_USER_FIELDS,
)
if SOCIAL_AUTH_FACEBOOK_KEY and SOCIAL_AUTH_FACEBOOK_SECRET:
    AUTHENTICATION_BACKENDS.append("social_core.backends.facebook.FacebookOAuth2")
if SOCIAL_AUTH_TWITTER_KEY and SOCIAL_AUTH_TWITTER_SECRET:
    AUTHENTICATION_BACKENDS.append("social_core.backends.twitter.TwitterOAuth")
if SOCIAL_AUTH_LINKEDIN_OAUTH2_KEY and SOCIAL_AUTH_LINKEDIN_OAUTH2_SECRET:
    AUTHENTICATION_BACKENDS.append("social_core.backends.linkedin.LinkedinOAuth2")\
if SOCIAL_AUTH_GOOGLE_OAUTH2_KEY and SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET:
    AUTHENTICATION_BACKENDS.append("social_core.backends.google.GoogleOAuth2")\
SOCIAL_AUTH_PIPELINE_MODULE = "apps.users.pipeline"

Export variables in ansible

SOCIAL_AUTH_FACEBOOK_KEY
SOCIAL_AUTH_FACEBOOK_SECRET
SOCIAL_AUTH_TWITTER_KEY
SOCIAL_AUTH_TWITTER_SECRET
SOCIAL_AUTH_LINKEDIN_KEY
SOCIAL_AUTH_LINKEDIN_SECRET
SOCIAL_AUTH_GOOGLE_KEY
SOCIAL_AUTH_GOOGLE_SECRET

Testing

Install the requirements from test/requirements.txt and run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baseapp-social-auth-0.2.8.tar.gz (15.9 kB view details)

Uploaded Source

File details

Details for the file baseapp-social-auth-0.2.8.tar.gz.

File metadata

  • Download URL: baseapp-social-auth-0.2.8.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for baseapp-social-auth-0.2.8.tar.gz
Algorithm Hash digest
SHA256 fc7c04ffaa81e5b27cd936a893e234dd9339f4dc3e0df68138b170769a060a48
MD5 50c9d5fe91a683b42599908506a0f0dc
BLAKE2b-256 6405029945b39c7cad4190a6cab0c42aa5bd389aa340102019efca0b4e626e3b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page