Clearpath-HQ / Clearpath_backend

De-coupled django backend of Clearpath
GNU General Public License v3.0
12 stars 0 forks source link

Google auth implemented #13

Open Surfskills opened 2 months ago

Surfskills commented 2 months ago

tested2

Title: Implement Google Social Authentication

Description:

This pull request adds support for Google social authentication to our application. The following changes have been made:

  1. Installed Required Packages:

    • Added google-auth and google-auth-oauthlib to the project dependencies.
  2. Configured Google Client ID:

    • Added a new environment variable GOOGLE_CLIENT_ID to store the Google OAuth client ID.
    • Loaded the GOOGLE_CLIENT_ID in settings.py.
  3. Created Google Authentication Utility:

    • Added a utility function validate_google_token to validate Google OAuth tokens using google.auth.transport.requests and google.oauth2.id_token.
  4. Updated User Model and Manager:

    • Ensured the auth_provider field has a default value for new users.
  5. Added Google Social Auth View:

    • Created GoogleSocialAuthView in the google_auth app to handle the authentication process.
    • The view validates the token, extracts user information, and handles user registration or authentication.
  6. Updated URLs:

    • Added a new endpoint for Google social authentication in urls.py.
  7. Debugging and Error Handling:

    • Added appropriate error handling for token validation and user authentication.
    • Included print statements for debugging (to be removed or replaced with proper logging in the future).

Testing:

bright2kwame commented 2 months ago

@Surfskills can we get this resolved quickly ??

Surfskills commented 2 months ago

@bright2kwame resolved