This project demonstrates how to set up Google OAuth 2.0 authentication using PHP and style your project with Tailwind CSS and Flowbite components.
Start by cloning the repository to your local environment:
git clone https://github.com/Dawn-o/Oauth-PHP.gitcd Oauth-PHPTo install Tailwind CSS and Flowbite as dependencies in your project, run the following command:
npm install -D tailwindcss flowbiteThis will add both Tailwind CSS and Flowbite as development dependencies in your project.
To configure your .env file for OAuth 2.0, follow these steps:
-
Create OAuth 2.0 Credentials:
-
Go to the Google Cloud Console.
-
Create a new project or select an existing one.
-
Navigate to "Credentials" and click on "Create Credentials" > "OAuth Client ID."
-
Set the Authorized redirect URI to:
http://localhost/Oauth/function/google_auth.phpAdjust this URI if necessary to match your local or production setup.
-
-
Update
.envFile:After creating the credentials, you will receive a Client ID and Client Secret. Add these to your
.envfile along with the redirect URI:CLIENT_ID='<YOUR_CLIENT_ID>' CLIENT_SECRET='<YOUR_CLIENT_SECRET>'
Replace <YOUR_CLIENT_ID> and <YOUR_CLIENT_SECRET> with the actual values obtained from Google Cloud Console.
To run the project, you can using XAMPP
-
Install and Configure XAMPP:
- Download and install XAMPP if you haven't already.
- Start the Apache and MySQL services from the XAMPP Control Panel.
-
Move Project to XAMPP Directory:
- Move your project directory (e.g.,
oauth-php) to thehtdocsdirectory inside your XAMPP installation (usually located atC:\xampp\htdocs).
- Move your project directory (e.g.,
-
Access the Project:
- Open your web browser and navigate to
http://localhost/oauth-php(or whatever the path is relative tohtdocs).
- Open your web browser and navigate to
-
Verify OAuth Configuration:
- Test the OAuth 2.0 authentication flow to ensure that your setup is correct. Follow the authentication process and check for any errors.
-
Check for Errors:
-
Monitor your browser console and XAMPP's Apache error logs for any issues during the authentication process and resolve them as needed.
-
Watch for any errors or issues in the browser console and terminal, and resolve them as needed.
-