Django-React-GoogleOauth2-Example
Django-React-GoogleOauth2-Example copied to clipboard
Prevent possible runtime errors
- Renamed
givenNameandfamilyNamevariables togiven_nameandfamily_nameto ensureprofile_datais properly obtained fromuser_dataas the user info endpoint (https://www.googleapis.com/oauth2/v3/userinfo)returnsgiven_nameandfamily_nameinstead of the former. -
app_namevariable inapi/urls.pyhelps preventNoReverseMatchErrorin GoogleLoginApi while reverse function to get api_uri from urls namespaces. This can also be fixed by replacing the second url pattern inconfig/urls.pywithpath('api/', include(('api.urls', 'api'), namespace='api')), -
redirect_uri mismatcherrors can easily arise from trailing slashes being the subtle difference between the authorized redirect URIs in the Google console and theredirect_urivalue used in the codebase. A quick warning on this can save someone hours of debugging. - Adding username to
REQUIRED_FIELDSinusers/models.pyhelps to prevent a TypeError from a missing required positional argument (username) in the create_superuser function in theUserManager. This makes it possible to create superusers for testing purposes - Added
issued_at’ as the fourth argument ofjwt_response_payload_handlerto fixTypeError` as a result of excessive arguments (4) coming from https://github.com/Styria-Digital/django-rest-framework-jwt/blob/master/src/rest_framework_jwt/views.py#L34 instead of expected three(3) arguments of the function. This error prevents the traditional email-password login flow from happening successfully.
Hello :wave:
We'll be moving this repository to our Django Styleguide Example - https://github.com/HackSoftware/Django-Styleguide-Example/issues/330 - so the examples are supported.