Skip to main content

DRF_social_auth is an ultra-lightweight solution for social authentication support in Django REST Framework.

Project description

drf_social_auth

drf_social_auth is an ultra-lightweight solution for social authentication support in Django REST Framework. And it supports Google Authentication out-of-box.


Source code https://github.com/coaxsoft/drf-social-auth/


Requirements

  • Python 3.6+
  • Django 3.0+
  • Django REST Framework 3.11+

Installation

pip install drf-social-auth

Usage

Use built-in Google Authentication

  1. You must specify the following Google settings in your settings.py:
GOOGLE_CLIENT_ID= 
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=
  1. Add the following to your urls.py.
from rest_framework_social_auth.google import GoogleLogin

urlpatterns = [
    path('google/', GoogleLogin.as_view(), name='google-login')
]
  1. It's done! You can send your code, grant_type and scope (if any) to this endpoint to retrieve profile info from Google Account.

Create your own solution for other social authentication provider

  1. You need to create an adapter for your provider.

This can be done by inheriting from Adapter abstract class and overriding get_access_token_data and get_profile_data methods.

You should also specify access_token_url and profile_url endpoints.

It is better to use GoogleAdapter in rest_framework_social_auth.google as an example.

from rest_framework_social_auth.adapter import Adapter

class YourProviderAdapter(Adapter):
    pass
  1. Now you need to create a View and specify your adapter.
from rest_framework_social_auth.views import SocialLoginView

class YourProviderLogin(SocialLoginView):
    adapter = YourProviderAdapter()
  1. Create an endpoint in urls.py using your View and you are good to go.

Testing

tox

License

This project is licensed under the terms of the ISC License

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

drf_social_auth-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drf_social_auth-0.1.0-py2.py3-none-any.whl (6.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file drf_social_auth-0.1.0.tar.gz.

File metadata

  • Download URL: drf_social_auth-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.0

File hashes

Hashes for drf_social_auth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 99bf7b4f8302f4cd6c49c99a2b6177e3b63ac614080f42003c0baf81b6b22ba9
MD5 1c4e6307f206ae9344698421aff3af38
BLAKE2b-256 3c0523fb9eef4ac32f4dc94b558ffbd74b9bd4b6c9f2454b0d793c40644b49f9

See more details on using hashes here.

File details

Details for the file drf_social_auth-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: drf_social_auth-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.0

File hashes

Hashes for drf_social_auth-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9c5ef25cc92e65dac89aedd7a319734ca4d270e6abac22cf8f3ecdb271cd11bb
MD5 e664f987caee2f866f4f8497c0473c63
BLAKE2b-256 4f406501fc06d05f0a339f20a599be95b09fb7831e8c7594efe7a48a0b51e1ac

See more details on using hashes here.

Supported by

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