PHPackages                             red-dott/google-oauth-login-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. red-dott/google-oauth-login-php

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

red-dott/google-oauth-login-php
===============================

This a simple package for php for authenticating user from Google using the OAuth 2.0

051PHP

Since Sep 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Amadeus-911/red-dot-Google-Login-php-package)[ Packagist](https://packagist.org/packages/red-dott/google-oauth-login-php)[ RSS](/packages/red-dott-google-oauth-login-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

red-dot-Google-Sign-In-php
==========================

[](#red-dot-google-sign-in-php)

A simple handler for php to use OAuth2.0 for authenticating using google

At first a google application has to be set up for client ID and Client Secret. Go to

Set up OAuth Consent Screen
===========================

[](#set-up-oauth-consent-screen)

Give app name -&gt; centact email address -&gt; application home page url (here localhost/Myapp) -&gt; give test email address and continue and Save.

Go to Credentials
=================

[](#go-to-credentials)

Create Credential -&gt;
Oauth Client Id -&gt; Web Application -&gt; add web app name -&gt; add redirect uri (the url where google will send back its response such as localhost/login.php)

Download the config JSON file containing client ID and Client Secret

Install composer (php package manager) from here

Setup using composer
====================

[](#setup-using-composer)

```
composer require red-dott/google-oauth-login-php:dev-main

```

Set up in your project with github
==================================

[](#set-up-in-your-project-with-github)

In your composer.json file add

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/Amadeus-911/red-dot-Google-Login-php-package.git"
        }
    ],
    "require": {
        "red-dott/google-oauth-login-php": "dev-main"
    }
}

```

on root folder of you project run

```
composer install

```

Setup in your project
=====================

[](#setup-in-your-project)

- refer to the sample/login.php

import it in your php file

```
require_once 'vendor/autoload.php';
use RedDot\GoogleOauthLoginPhp\GoogleClient;

```

First create the GoogleClient with your google app client\_id and client\_secret then generate authUrl where the login button will hit

```
$client = new GoogleClient($client_id, $client_secret, $redirect_uri);
$authUrl = $client->buildAuthUrl();

```

add it to your google sign in button like this

```
