Skip to content

Commit

Permalink
Merge pull request #177 from wagnerdelima/bug/investigation
Browse files Browse the repository at this point in the history
bug: fix extra headers returned in the /convert-token endpoint. 
Fixes #147
  • Loading branch information
wagnerdelima authored Apr 26, 2023
2 parents 4b3cfd2 + acb3a45 commit 540082f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
2 changes: 2 additions & 0 deletions docs/source/application.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ Screenshot of the new application creation.
:class: png
:width: 1200
:alt: Adding a new application to your drf-social-oauth2 installation.

Please, read the :ref:`integration` in order to integrate social libraries into your project.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
project = 'drf-social-oauth2'
copyright = '2023, Wagner de Lima'
author = 'Wagner de Lima'
release = '2.1.0'
release = '2.1.1'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This framework is published at the PyPI, install it with pip:

.. code-block:: console
$ pip install drf_social_oauth2==2.1.0
$ pip install drf_social_oauth2==2.1.1
To enable OAuth2 social authentication support for your Django REST Framework application, you need to install
Expand Down
8 changes: 8 additions & 0 deletions docs/source/integration.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _integration:

Integration Social Backends
===========================

Expand Down Expand Up @@ -247,3 +249,9 @@ The Client ID should be added on SOCIAL_AUTH_GITHUB_KEY and the `SOCIAL_AUTH_GIT

Now, visit https://github.com/settings/tokens and create a new token. Select the user checkbox, as to grant user access.
The click on the Generate Token button. Use the access token as the token parameter in the /convert-token endpoint.

Other Backend Integration
=========================

DRF-Social-Oauth2 is not only limited to Google, Facebook and Github. You can integrate with every backend described
at the Python Social Oauth backend integrations.
2 changes: 1 addition & 1 deletion drf_social_oauth2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
and a ton more!
"""

__version__ = '2.1.0'
__version__ = '2.1.1'

try:
from secrets import SystemRandom
Expand Down
17 changes: 3 additions & 14 deletions drf_social_oauth2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ def post(self, request: Request, *args, **kwargs):
status=HTTP_400_BAD_REQUEST,
)

response = Response(data=json_loads(body), status=status)
for k, v in headers.items():
response[k] = v
return response
return Response(data=json_loads(body), status=status)


class ConvertTokenView(CsrfExemptMixin, OAuthLibMixin, APIView):
Expand Down Expand Up @@ -137,11 +134,7 @@ def post(self, request: Request, *args, **kwargs):
status=HTTP_400_BAD_REQUEST,
)

response = Response(data=json_loads(body), status=status)

for k, v in headers.items():
response[k] = v
return response
return Response(data=json_loads(body), status=status)


class RevokeTokenView(CsrfExemptMixin, OAuthLibMixin, APIView):
Expand All @@ -163,14 +156,10 @@ def post(self, request: Request, *args, **kwargs):
request._request.POST[key] = value

url, headers, body, status = self.create_revocation_response(request._request)
response = Response(
return Response(
data=json_loads(body) if body else '', status=status if body else 204
)

for k, v in headers.items():
response[k] = v
return response


class InvalidateSessions(APIView):
"""
Expand Down

0 comments on commit 540082f

Please sign in to comment.