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 2w ago

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 13% 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://avatars.githubusercontent.com/u/683538?v=4)[Pablo Prieto](/maintainers/pabloprieto)[@pabloprieto](https://github.com/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

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.2M17](/packages/kartik-v-yii2-password)

PHPackages © 2026

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