Skip to content

Commit

Permalink
Merge branch 'master' into gekoke/bump-django-allauth
Browse files Browse the repository at this point in the history
  • Loading branch information
iMerica committed Jul 7, 2024
2 parents 7eb2ec9 + 429a270 commit b53265d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ You're good to go now!
Registration (optional)
-----------------------

1. If you want to enable standard registration process you will need to install ``django-allauth`` by using ``pip install 'dj-rest-auth[with_social]'``.
1. If you want to enable standard registration process you will need to install ``django-allauth`` by using ``pip install 'dj-rest-auth[with-social]'``.

2. Add ``django.contrib.sites``, ``allauth``, ``allauth.account``, ``allauth.socialaccount`` and ``dj_rest_auth.registration`` apps to INSTALLED_APPS in your django settings.py:

Expand Down Expand Up @@ -182,12 +182,12 @@ If you are using GitHub for your social authentication, it uses code and not Acc
...,
path('dj-rest-auth/github/', GitHubLogin.as_view(), name='github_login')
]
Google
######
If you are using Google for your social authentication, you can choose ``Authorization Code Grant`` or ``Implicit Grant`` (deprecated).
Serializer of dj-rest-auth accepts both ``code`` and ``token``
Serializer of dj-rest-auth accepts both ``code`` and ``token``

1. Add ``allauth.socialaccount`` and ``allauth.socialaccount.providers.google`` apps to INSTALLED_APPS in your django settings.py:

Expand All @@ -208,20 +208,20 @@ Serializer of dj-rest-auth accepts both ``code`` and ``token``
'allauth.socialaccount.providers.google',
)
3. Create new view as a subclass of ``dj_rest_auth.views.SocialLoginView`` with ``GoogleOAuth2Adapter`` adapter, an ``OAuth2Client`` and a callback_url as attributes:

.. code-block:: python
from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
from allauth.socialaccount.providers.oauth2.client import OAuth2Client
from dj_rest_auth.registration.views import SocialLoginView
class GoogleLogin(SocialLoginView): # if you want to use Authorization Code Grant, use this
adapter_class = GoogleOAuth2Adapter
callback_url = CALLBACK_URL_YOU_SET_ON_GOOGLE
client_class = OAuth2Client
class GoogleLogin(SocialLoginView): # if you want to use Implicit Grant, use this
adapter_class = GoogleOAuth2Adapter
Expand All @@ -234,7 +234,7 @@ Serializer of dj-rest-auth accepts both ``code`` and ``token``
path('dj-rest-auth/google/', GoogleLogin.as_view(), name='google_login')
]
5. Retrive code (or token)
5. Retrieve code (or token)
By accessing Google's endpoint, you can get ``code`` or ``token``

If you're using Authorization Code Grant, you can get code from following URL
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
'djangorestframework>=3.13.0',
],
extras_require={
'with_social': ['django-allauth[socialaccount]>=0.62.0,<=0.62.1'],
'with-social': ['django-allauth>=0.56.0,<0.62.0'],
},
tests_require=[
'coveralls>=1.11.1',
Expand Down

0 comments on commit b53265d

Please sign in to comment.