django-google-oauth-rest


Namedjango-google-oauth-rest JSON
Version 1.0 PyPI version JSON
download
home_pagehttps://github.com/ahmad-00/django_google_oauth_rest
Summary"Django Google auth"
upload_time2022-12-04 21:09:06
maintainer
docs_urlNone
authorAhmad Mohammadi
requires_python>=3
licenseMIT
keywords django google auth oauth
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            **Django Google Auth**
======================

This project help with Google Authentication flow when you prefer API
approach. It uses existing User model in your database and no other
tables are created. It also lets you modify parameters based on your
business logic and current authentication flow.

**Quick Start**
---------------

1. Add “google_auth” to your INSTALLED_APPS setting like this:

.. code-block:: python

    INSTALLED_APPS = [
        ...
        'google_auth',
    ]

2. Add “email” field to your user table if it doesn’t already exist.

3. (OPTIONAL) To have user retrieved info saved in your add these fields
   to your user table:

   -  given_name
   -  family_name

4. Add a new url to your projects url.py like this:

.. code-block:: python

   re_path('auth/url', views.AuthURL.as_view(), name="auth_url")

5. Create a new view which is a subclass of ‘**AuthCallback**’ like
   this:

.. code-block:: python

   class CallbackView(AuthCallback):
      def get(self, request):
         user = super(CallbackView, self).get(request)         
         # create new token and authenticate user. Return token and required parameters here``

6. Add another new url to your projects url.py like this:

.. code-block:: python

   re_path('auth/calback', views.CallbackView.as_view(), name="auth_calback_url")

**Configuration parameter**
---------------------------

-  AUTH_USER_MODEL: Authentication user table in your models
-  CLIENT_ID: Retrieved from Google console
-  CLIENT_SECRET: Retrieved from Google console
-  REDIRECT_URI: Redirect url same as redirect url in google console
   (Usually it should route to your front-end url)
-  VALIDATE_STATE: (OPTIONAL) state is a server side generated security
   feature suggested by google. It will be saved in session. default
   value it True. If set to False it will bypass this security check.
-  SET_REGISTER_USER_FIELD: (OPTIONAL) If you want to set some value in
   User table after login/register process is successful, you can set it
   here. In example below, we set user verified field to True when
   login/register process is successful:

   .. code-block:: python

      SET_REGISTER_USER_FIELD = {
        "verified": True
      }

-  USER_INFO_REQUEST_URI: (OPTIONAL) Google verification url. Should be
   fine with default value.

**URLs Flow**
--------------

1. First call ‘auth/url’ by POST(Empty body) or GET Method.

   -  GET method will return generated URL in JSON response. Your front
      end should redirect to this URL.
   -  POST method will return 302 status code with redirect url.

2. After redirecting to received URL from step 1, user can verify from
   Google. If verification is successful Google will call your
   redirect_uri.
3. when redirect_uri is called your frontend should call the Callback
   url you already created (step 6 in Quick start).

   -  IMPORTANT: You must add all query params received from Google in
      this step to ‘auth/callback’ as query params.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ahmad-00/django_google_oauth_rest",
    "name": "django-google-oauth-rest",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "django google auth oauth",
    "author": "Ahmad Mohammadi",
    "author_email": "mohammadi.ahmad00@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/72/74/838d07ea8a3fb097b7d95e89cc15312b23b1c96d4366555c09db985fc532/django-google-oauth-rest-1.0.tar.gz",
    "platform": null,
    "description": "**Django Google Auth**\n======================\n\nThis project help with Google Authentication flow when you prefer API\napproach. It uses existing User model in your database and no other\ntables are created. It also lets you modify parameters based on your\nbusiness logic and current authentication flow.\n\n**Quick Start**\n---------------\n\n1. Add \u201cgoogle_auth\u201d to your INSTALLED_APPS setting like this:\n\n.. code-block:: python\n\n    INSTALLED_APPS = [\n        ...\n        'google_auth',\n    ]\n\n2. Add \u201cemail\u201d field to your user table if it doesn\u2019t already exist.\n\n3. (OPTIONAL) To have user retrieved info saved in your add these fields\n   to your user table:\n\n   -  given_name\n   -  family_name\n\n4. Add a new url to your projects url.py like this:\n\n.. code-block:: python\n\n   re_path('auth/url', views.AuthURL.as_view(), name=\"auth_url\")\n\n5. Create a new view which is a subclass of \u2018**AuthCallback**\u2019 like\n   this:\n\n.. code-block:: python\n\n   class CallbackView(AuthCallback):\n      def get(self, request):\n         user = super(CallbackView, self).get(request)         \n         # create new token and authenticate user. Return token and required parameters here``\n\n6. Add another new url to your projects url.py like this:\n\n.. code-block:: python\n\n   re_path('auth/calback', views.CallbackView.as_view(), name=\"auth_calback_url\")\n\n**Configuration parameter**\n---------------------------\n\n-  AUTH_USER_MODEL: Authentication user table in your models\n-  CLIENT_ID: Retrieved from Google console\n-  CLIENT_SECRET: Retrieved from Google console\n-  REDIRECT_URI: Redirect url same as redirect url in google console\n   (Usually it should route to your front-end url)\n-  VALIDATE_STATE: (OPTIONAL) state is a server side generated security\n   feature suggested by google. It will be saved in session. default\n   value it True. If set to False it will bypass this security check.\n-  SET_REGISTER_USER_FIELD: (OPTIONAL) If you want to set some value in\n   User table after login/register process is successful, you can set it\n   here. In example below, we set user verified field to True when\n   login/register process is successful:\n\n   .. code-block:: python\n\n      SET_REGISTER_USER_FIELD = {\n        \"verified\": True\n      }\n\n-  USER_INFO_REQUEST_URI: (OPTIONAL) Google verification url. Should be\n   fine with default value.\n\n**URLs Flow**\n--------------\n\n1. First call \u2018auth/url\u2019 by POST(Empty body) or GET Method.\n\n   -  GET method will return generated URL in JSON response. Your front\n      end should redirect to this URL.\n   -  POST method will return 302 status code with redirect url.\n\n2. After redirecting to received URL from step 1, user can verify from\n   Google. If verification is successful Google will call your\n   redirect_uri.\n3. when redirect_uri is called your frontend should call the Callback\n   url you already created (step 6 in Quick start).\n\n   -  IMPORTANT: You must add all query params received from Google in\n      this step to \u2018auth/callback\u2019 as query params.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\"Django Google auth\"",
    "version": "1.0",
    "split_keywords": [
        "django",
        "google",
        "auth",
        "oauth"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "3ec9d526cd7ec3e01e3622455e66691c",
                "sha256": "ce8eb9f425c872d510a47e04faeea318b499232b5e64b277d3ad6d0eb5357c20"
            },
            "downloads": -1,
            "filename": "django_google_oauth_rest-1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3ec9d526cd7ec3e01e3622455e66691c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 6286,
            "upload_time": "2022-12-04T21:09:05",
            "upload_time_iso_8601": "2022-12-04T21:09:05.277869Z",
            "url": "https://files.pythonhosted.org/packages/13/44/24fab0020469e095c9de76bec07d142cd2b64dfbdbd02a576b87e38bccca/django_google_oauth_rest-1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "779b956f841bad9469a98f45aaa63289",
                "sha256": "9f0c029bede9a05dbae6d7d85eaa04bc10ce78620cfdd6b4c761339432669c53"
            },
            "downloads": -1,
            "filename": "django-google-oauth-rest-1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "779b956f841bad9469a98f45aaa63289",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 5294,
            "upload_time": "2022-12-04T21:09:06",
            "upload_time_iso_8601": "2022-12-04T21:09:06.833936Z",
            "url": "https://files.pythonhosted.org/packages/72/74/838d07ea8a3fb097b7d95e89cc15312b23b1c96d4366555c09db985fc532/django-google-oauth-rest-1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-04 21:09:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ahmad-00",
    "github_project": "django_google_oauth_rest",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-google-oauth-rest"
}
        
Elapsed time: 0.01832s