thecuriousteam / Curious-Community-Website

An open-source project initiated by Curious Business Solutions Private Limited, called Curious Community, aims to bring together technology enthusiasts. The platform is designed to foster a space where people can share knowledge, learn, and grow within a supportive community by helping one another.
https://curiousdevelopers.in
5 stars 8 forks source link

Add "Sign in with Google" Button #8

Open jenyyy4 opened 1 month ago

jenyyy4 commented 1 month ago

Feature Request: Add "Sign in with Google" Button

Summary

Request to integrate Google Sign-In functionality by adding a "Sign in with Google" button to allow users to quickly and securely authenticate using their Google account.

Motivation

Adding a "Sign in with Google" button would:

Use Cases

  1. Faster User Onboarding: Users can sign in to the platform using their Google account, which reduces friction and improves sign-up conversion rates.
  2. Secure Authentication: Using OAuth 2.0 for Google Sign-In ensures secure authentication, minimizing the risk of password breaches.
  3. Consistent User Experience: Many users are familiar with Google Sign-In, offering them a streamlined and trustworthy login experience.

Proposed Solution

The "Sign in with Google" button should be integrated into the existing login page or modal. The button would allow users to authenticate with their Google accounts via the OAuth 2.0 protocol.

Steps to Implement:

  1. Google Developer Console Setup:

    • Create a new project in the Google Developer Console.
    • Enable the Google Identity Services API.
    • Generate the OAuth 2.0 Client ID and configure authorized redirect URIs.
  2. Frontend:

    • Add the Google Sign-In button to the login page using Google's Identity Services SDK.
    • Example of a Google Sign-In button integration:
      <div id="g_id_onload"
        data-client_id="YOUR_GOOGLE_CLIENT_ID"
        data-callback="handleCredentialResponse">
      </div>
      <div class="g_id_signin" data-type="standard"></div>
  3. Backend:

    • Implement backend logic to handle the authentication flow.
    • Use the token provided by Google to verify the user's identity and sign them in.
    • Example of verifying the Google token on the server (Node.js example):

      const {OAuth2Client} = require('google-auth-library');
      const client = new OAuth2Client(CLIENT_ID);
      
      async function verify(token) {
      const ticket = await client.verifyIdToken({
         idToken: token,
         audience: CLIENT_ID,
      });
      const payload = ticket.getPayload();
      const userid = payload['sub'];
      }
  4. UI Design:

  5. Error Handling:

    • Implement proper error handling for cases where Google Sign-In fails or is denied by the user.
Screenshot 2024-10-01 at 11 54 01 PM
jenyyy4 commented 1 month ago

@thecuriousteam I would like to work on this issue, please assign it to me.