Coder Social home page Coder Social logo

php-google-login's Introduction

PHP-Google-Login

This project is an implementation of a simple Google Login system in PHP.

Requirements

  1. PHP >= 5.6
  2. Composer
  3. Google API Console Project with enabled Google+ API and Google OAuth 2.0 API

Setup Guide

  1. Clone this repository:
git clone https://github.com/[username]/PHP-Google-Login.git
  1. Navigate to the project directory: cd PHP-Google-Login

  2. Install the dependencies using Composer: composer install

  3. Create a new project in Google API Console.

  4. Enable Google+ API and Google OAuth 2.0 API for the project.

  5. Create a new OAuth client ID.

  6. Update the client ID, client secret and redirect URI in index.php:

$client->setClientId('YOUR_CLIENT_ID');
$client->setClientSecret('YOUR_CLIENT_SECRET');
$client->setRedirectUri('YOUR_REDIRECT_URI');
  1. Start the PHP built-in server:
php -S localhost:8000
  1. Access the application in your browser at http://localhost:8000.

Common Errors and Solutions

Missing dependencies:
If you get an error related to missing classes, make sure you have installed the dependencies using Composer.

Undefined index:
If you get an error related to undefined index in $_GET['code'], make sure that you have granted access to your Google account and the authorization code is being passed in the URL.

Redirect URI mismatch:
If you get an error related to redirect URI mismatch, make sure that the redirect URI in your OAuth client ID configuration in Google API Console matches the one in index.php.

Troubleshooting

If you face any issues, feel free to create an issue in this repository or ask for help in the comments section.

php-google-login's People

Contributors

olivierluethy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.