PHPackages                             pabloprieto/oauth2 - 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. pabloprieto/oauth2

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

pabloprieto/oauth2
==================

A simple OAuth2 client working with Zend\\Http

08PHP

Since Apr 18Pushed 12y ago1 watchersCompare

[ Source](https://github.com/pabloprieto/oauth2)[ Packagist](https://packagist.org/packages/pabloprieto/oauth2)[ RSS](/packages/pabloprieto-oauth2/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

OAuth2 client
=============

[](#oauth2-client)

A simple OAuth2 client working with Zend\\Http

Exemple with Google+ API
------------------------

[](#exemple-with-google-api)

```
$googleClient = new OAuth2\Client('YOUR_API_KEY', 'YOUR_API_SECRET');
$redirectUri  = 'http://domain/redirect-uri';

if (isset($_GET['code'])) {

    $params = array(
        'code'         => $_GET['code'],
        'redirect_uri' => $redirectUri,
    );

    $response = $googleClient->getAccessToken(
        'https://accounts.google.com/o/oauth2/token',
        OAuth2\Client::GRANT_TYPE_AUTH_CODE,
        $params
    );

    $token = json_decode($response);
    $googleClient->setAccessToken($token->access_token)

    $response = $googleClient->fetch('https://www.googleapis.com/plus/v1/people/me');

    var_dump(json_decode($response->getBody()));

} else {

    $scopes = array(
        'https://www.googleapis.com/auth/plus.login',
        'https://www.googleapis.com/auth/plus.me'
    );

    $params = array(
        'state'        => uniqid('', true),
        'redirect_uri' => $redirectUri,
        'scope'        => implode(' ', $scopes)
    );

    $authUrl = $googleClient->getAuthenticationUrl('https://accounts.google.com/o/oauth2/auth', $params);

    header('Location: ' . $authUrl);
    exit;

}

```

License
-------

[](#license)

Released under the MIT License

Contact
-------

[](#contact)

Pablo Prieto, [pabloprieto.net](http://pabloprieto.net/)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ece6076fabee090769bb8f8e03fafd1ebbec66bd0b12a8db3b4808fc5a49dc4?d=identicon)[pabloprieto](/maintainers/pabloprieto)

---

Top Contributors

[![pabloprieto](https://avatars.githubusercontent.com/u/683538?v=4)](https://github.com/pabloprieto "pabloprieto (2 commits)")

### Embed Badge

![Health badge](/badges/pabloprieto-oauth2/health.svg)

```
[![Health](https://phpackages.com/badges/pabloprieto-oauth2/health.svg)](https://phpackages.com/packages/pabloprieto-oauth2)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
