PHPackages                             lcmaquino/googleoauth2 - 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. lcmaquino/googleoauth2

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

lcmaquino/googleoauth2
======================

GoogleOAuth2 adds to Laravel a service provider for Google OAuth 2.0 authentication.

v1.0.6(4y ago)412.7k↑114.3%3GPL-3.0-or-laterPHPPHP ^7.2

Since Dec 30Pushed 4y ago1 watchersCompare

[ Source](https://github.com/lcmaquino/googleoauth2)[ Packagist](https://packagist.org/packages/lcmaquino/googleoauth2)[ Docs](https://github.com/lcmaquino/googleoauth2)[ RSS](/packages/lcmaquino-googleoauth2/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

Introduction
------------

[](#introduction)

GoogleOAuth2 is a Laravel package for Google OAuth 2.0 authentication. It was created based on [Laravel Socialite](https://github.com/laravel/socialite)but with focus only on Google.

GoogleOAuth2 implements the main process for OAuth 2:

- authentication — get the user coming from Google authentication;
- get user information — get the user data from their Google account;
- refresh token — refresh the user's access token;
- revoke token — revoke the user's access token.

For more information about Google OAuth 2.0, please see

Installation
------------

[](#installation)

It can be installed as usual for laravel packages:

```
$ cd /path/to/your/laravel/root
$ composer require lcmaquino/googleoauth2
$ php artisan vendor:publish --provider="Lcmaquino\GoogleOAuth2\GoogleOAuth2Provider"

```

Laravel should automatically include `Lcmaquino\GoogleOAuth2\GoogleOAuth2Provider`as a service provider and include `GoogleAuth` as an alias for `Lcmaquino\GoogleOAuth2\Facades\GoogleOAuth2::class`.

It can be done manually editing `config/app.php` to look like:

```
    'providers' => [

        //More Service Providers...

        /*
         * Package Service Providers...
         */
        Lcmaquino\GoogleOAuth2\GoogleOAuth2Provider::class,
    ],

    'aliases' => [

        //More aliases...

        'GoogleAuth' => Lcmaquino\GoogleOAuth2\Facades\GoogleOAuth2::class,
    ],

```

Configuration
-------------

[](#configuration)

Before using GoogleOAuth2, you need to set up an [OAuth 2.0 client ID](https://support.google.com/cloud/answer/6158849?hl=en). It will provide a *client id*, a *client secret*, and a *redirect uri* for your application. These parameters should be placed in your `.env` Laravel configuration file.

```
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=

```

It will be loaded by your application when reading the file `config/googleoauth2.php`:

```
