This guide provides step-by-step instructions on how to integrate Google authentication into your application.
npm create vite@latest
npm install
To integrate Google authentication into your application, begin by installing the [@react-oauth/google](https://github.com/MomenSherif/react-oauth) package. This package is Google's Identity Services SDK, which enables seamless integration of Google login into your application and facilitates secure access to Google APIs.
https://github.com/MomenSherif/react-oauth
A client ID is essential for OAuth 2.0 authentication between the client and server. To obtain a Google Client ID, follow these steps:
-
Go to your Google Cloud Console.
-
Create a new project and name it according to your preference.
-
Select your project from the dashboard.
To create your web client ID, follow these steps in your project's Google Cloud Console:
-
Click on the "Credentials" tab in the left-side menu.
-
Click on "CREATE CREDENTIALS" at the top of the page.
-
Choose the "OAuth client ID" option.
-
Select "Web application" as the application type if you are integrating it into a React app.
-
Name your client ID descriptively, e.g., "Web ID."
-
Add the following URLs:
- Authorized JavaScript Origins: URLs from which your application originates the login (e.g., localhost, localhost:3000 for React developers, or your hosted URL).
- Authorized Redirect URLs: The URL Google will redirect the user to after a successful login.
Example for localhost:
- Authorized JavaScript Origins: http://localhost:3000
- Authorized Redirect URLs: http://localhost
-
Click the "Create" button to generate your web client ID.
-
Copy your newly created web client ID from the dashboard.
Now that you have your web client ID, you can proceed to integrate Google login into your React app using the acquired credentials.
npm run dev
Happy coding and enjoy the benefits of Google authentication in your application! 🚀🔑