PHPackages                             codeinc/google-oauth2-middleware - 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. codeinc/google-oauth2-middleware

AbandonedArchivedLibrary

codeinc/google-oauth2-middleware
================================

A PSR-15 middleware managing Google OAuth2 authentication using JSON web tokens

1.3.1(7y ago)026[1 issues](https://github.com/CodeIncHQ/GoogleOAuth2Middleware/issues)MITPHPPHP &gt;=7.1

Since Mar 29Pushed 7y ago1 watchersCompare

[ Source](https://github.com/CodeIncHQ/GoogleOAuth2Middleware)[ Packagist](https://packagist.org/packages/codeinc/google-oauth2-middleware)[ Docs](https://github.com/CodeIncHQ/GoogleOAuth2Middleware)[ RSS](/packages/codeinc-google-oauth2-middleware/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (10)Versions (20)Used By (0)

Google OAuth 2 Middleware
=========================

[](#google-oauth-2-middleware)

`GoogleOAuth2Middleware` is a [PSR-15](https://www.php-fig.org/psr/psr-15/) middleware written in PHP 7 intended to manage Google OAuth2 authentication using JSON web tokens or the PHP session. The interactions with Google are made using the [Google API PHP client](https://github.com/google/google-api-php-client). The JSON web tokens are generated and read by the [Firebase JWT implementation](https://github.com/firebase/php-jwt).

The authentication informations ([`AuthToken`](src/AuthToken.php) object) are stored using a storage driver class (implementing [`AuthTokenStorageDriverInterface`](src/AuthTokenStorage/AuthTokenStorageDriverInterface.php)) either in a JSON web token cookie using [`JwtStorageDriver`](src/AuthTokenStorage/JwtStorageDriver.php) or in the PHP session (`$_SESSION` array) using [`SessionStorageDriver`](src/AuthTokenStorage/SessionStorageDriver.php).

Once the user is authenticated, either when receiving an auth code from Google or using the auth cookie, the user informations are made available in an attribute of the [PSR-7](https://www.php-fig.org/psr/psr-7/) request the called `auth` (by default).

You can disconnect the current user by sending a PSR-7 response implementing [`LogoutResponseInterface`](src/Responses/LogoutResponseInterface.php).

Usage
-----

[](#usage)

```
