Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pvfarooq/tfora_social_auth
https://github.com/pvfarooq/tfora_social_auth
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/pvfarooq/tfora_social_auth
- Owner: pvfarooq
- License: mit
- Created: 2021-07-30T15:03:43.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-04T15:45:06.000Z (over 3 years ago)
- Last Synced: 2025-01-03T11:19:40.826Z (6 days ago)
- Language: Python
- Size: 49.8 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tfora_social_auth
Easy django rest auth integration for social applications. (currently supports Google and Facebook)
## Quick Setup
Install package
pip install tfora-social-auth
Add `tfora_social_auth` app to INSTALLED_APPS in your django settings.py:
```python
INSTALLED_APPS = [
...
'rest_framework',
'tfora_social_auth',
...
]
```python manage.py migrate
#### Add URL patterns
```python
from tfora_social_auth.views import ( GoogleSocialAuthView, FacebookSocialAuthView )urlpatterns = [
path('social/google/', GoogleSocialAuthView.as_view()),
path('social/facebook/', FacebookSocialAuthView.as_view()),
]```
##### For Google login
- POST with "auth_token".
- Send an "idtoken" as from google to get user information##### For Facebook login
- POST with "auth_token".
- Send an access token as from facebook to get user information##### Extra token payload
You can add extra payload data to access token by the following method```python
from rest_framework_simplejwt.tokens import RefreshTokenclass CustomUserModel(AbstractUser):
...
@staticmethod
def get_token(user):
token = RefreshToken.for_user(user)
token["extra_key"] = "extra_value"
return token
...
```