Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
pvfarooq authored Sep 4, 2021
1 parent d6828d0 commit eb4e242
Showing 1 changed file with 47 additions and 24 deletions.
71 changes: 47 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,65 @@
# tfora_social_auth

##### Easy django rest auth integration for social applications. (currently supports Google and Facebook)
Easy django rest auth integration for social applications. (currently supports Google and Facebook)

### Installation

`pip install tfora-social-auth
`
###### INSTALLED_APPS = [
## Quick Setup

Install package

` 'tfora_social_auth'
`
pip install tfora-social-auth

###### ]

`python manage.py migrate`
Add `tfora_social_auth` app to INSTALLED_APPS in your django settings.py:

###### in urls
```python
INSTALLED_APPS = [
...
'rest_framework',
'tfora_social_auth',
...
]
```

`from tfora_social_auth.views import (
GoogleSocialAuthView,
FacebookSocialAuthView
)`

`path('social/google/', GoogleSocialAuthView.as_view()),
`
python manage.py migrate

`path('social/facebook/', FacebookSocialAuthView.as_view()),
`

### For Google login
#### Add URL patterns

###### POST with "auth_token".
```python
from tfora_social_auth.views import ( GoogleSocialAuthView, FacebookSocialAuthView )

###### Send an "idtoken" as from google to get user information
urlpatterns = [
path('social/google/', GoogleSocialAuthView.as_view()),
path('social/facebook/', FacebookSocialAuthView.as_view()),
]

### For Facebook login
```

###### POST with "auth_token".

###### Send an access token as from facebook to get user information
##### 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 RefreshToken

class CustomUserModel(AbstractUser):
...
@staticmethod
def get_token(user):
token = RefreshToken.for_user(user)
token["extra_key"] = "extra_value"
return token
...


```

0 comments on commit eb4e242

Please sign in to comment.