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.9.tar.gz (15.3 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for baseapp-social-auth-0.2.9.tar.gz
Algorithm Hash digest
SHA256 4b894c25c81a5b3a0ec430555c8f306b49103bf79c632d2900d6313efc3e62ad
MD5 fda4ca6bde6db811940caf41c950289e
BLAKE2b-256 f7142ab3f767534f114ec885f61e7fc102d5a921e294f3b54c132403bfb6ee15

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