Django-React-GoogleOauth2-Example icon indicating copy to clipboard operation
Django-React-GoogleOauth2-Example copied to clipboard

Prevent possible runtime errors

Open Basit-Balogun10 opened this issue 3 years ago • 1 comments

  • Renamed givenName and familyName variables to given_name and family_name to ensure profile_data is properly obtained from user_data as the user info endpoint (https://www.googleapis.com/oauth2/v3/userinfo)returns given_name and family_name instead of the former.
  • app_name variable in api/urls.py helps prevent NoReverseMatchError in GoogleLoginApi while reverse function to get api_uri from urls namespaces. This can also be fixed by replacing the second url pattern in config/urls.py with path('api/', include(('api.urls', 'api'), namespace='api')),
  • redirect_uri mismatch errors can easily arise from trailing slashes being the subtle difference between the authorized redirect URIs in the Google console and the redirect_uri value used in the codebase. A quick warning on this can save someone hours of debugging.
  • Adding username to REQUIRED_FIELDS in users/models.py helps to prevent a TypeError from a missing required positional argument (username) in the create_superuser function in the UserManager. This makes it possible to create superusers for testing purposes
  • Added issued_at’ as the fourth argument of jwt_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.

Basit-Balogun10 avatar Jun 09 '22 00:06 Basit-Balogun10

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.

RadoRado avatar Feb 02 '23 14:02 RadoRado