PHPackages                             allovince/evaoauth - 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. allovince/evaoauth

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

allovince/evaoauth
==================

EvaOAuth is an abstract interface to setup OAuth client, both support OAuth1.0a / OAuth2.

1.0.2(10y ago)25121965[3 issues](https://github.com/EvaEngine/EvaOAuth/issues)BSD-3-ClausePHPPHP &gt;=5.4

Since Aug 21Pushed 7y ago23 watchersCompare

[ Source](https://github.com/EvaEngine/EvaOAuth)[ Packagist](https://packagist.org/packages/allovince/evaoauth)[ Docs](http://avnpc.com/)[ RSS](/packages/allovince-evaoauth/feed)WikiDiscussions master Synced yesterday

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

EvaOAuth
========

[](#evaoauth)

[![Latest Stable Version](https://camo.githubusercontent.com/d315e35273b01fbcd0dbdba1fea3e3600a0a24c0de1488fa4a912bc20ad69c3b/68747470733a2f2f706f7365722e707567782e6f72672f657661656e67696e652f6576612d6f617574682f762f737461626c652e737667)](https://packagist.org/packages/evaengine/eva-oauth)[![License](https://camo.githubusercontent.com/1f98104601cd30c9c73c766cecec6dfd7d1b04458be29fdd06215c04f19cd53e/68747470733a2f2f706f7365722e707567782e6f72672f657661656e67696e652f6576612d6f617574682f6c6963656e73652e737667)](https://packagist.org/packages/evaengine/eva-oauth)[![Build Status](https://camo.githubusercontent.com/62f83a366b498da4b6bddd4eadce40d75f35c1ce431bd8f00492cd34676132d8/68747470733a2f2f7472617669732d63692e6f72672f416c6c6f56696e63652f4576614f417574682e7376673f6272616e63683d666561747572652532467265666163746f72696e67)](https://travis-ci.org/AlloVince/EvaOAuth)[![Coverage Status](https://camo.githubusercontent.com/dc0d8ec170306b7cedb9888278a2f6682fa997b19b3ac9a8e44eaf941c5b8436/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f416c6c6f56696e63652f4576614f417574682f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/AlloVince/EvaOAuth?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e81f487f416caa8950cbbbfb03d990676cef1a757b1629a8af802eab47d9fa00/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416c6c6f56696e63652f4576614f417574682f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/AlloVince/EvaOAuth/?branch=master)

EvaOAuth provides a standard interface for OAuth1.0 / OAuth2.0 client authorization, it is easy to integrate with any PHP project by very few lines code.

[中文文档](http://avnpc.com/pages/evaoauth)

Features
--------

[](#features)

- **Standard interface**, same code for both OAuth1.0 and OAuth2.0 different workflow, receiving token and user info as same format either.
- **Fully tested**
- **Easy to debug**, enable debug mode will record every request and response, help you find out problems quickly.
- **Out-of-the-box**, already supported most popular websites including Facebook. Twitter, etc.
- **Scalable**, integrate a new oauth website just need 3 lines code.

Quick Start
-----------

[](#quick-start)

EvaOAuth can be found on [Packagist](https://packagist.org/packages/evaengine/eva-oauth). The recommended way to install this is through composer.

Edit your composer.json and add:

```
{
    "require": {
        "evaengine/eva-oauth": "~1.0"
    }
}
```

And install dependencies:

```
curl -sS https://getcomposer.org/installer | php
php composer.phar install
```

Let's start a example of Facebook Login, if you have already have a Facebook developer account and created an app, prepare a request.php as below:

```
$service = new Eva\EvaOAuth\Service('Facebook', [
    'key' => 'You Facebook App ID',
    'secret' => 'You Facebook App Secret',
    'callback' => 'http://localhost/EvaOAuth/example/access.php'
]);
$service->requestAuthorize();
```

Run request.php in browser, will be redirected to Facebook authorization page. After user confirm authorization, prepare the access.php for callback:

```
$token = $service->getAccessToken();
```

Once access token received, we could use access token to visit any protected resources.

```
$httpClient = new Eva\EvaOAuth\AuthorizedHttpClient($token);
$response = $httpClient->get('https://graph.facebook.com/me');
```

That's it, more usages please check [examples](https://github.com/AlloVince/EvaOAuth/tree/master/examples) and [wiki](https://github.com/AlloVince/EvaOAuth/wiki).

Providers
---------

[](#providers)

EvaOAuth supports most popular OAuth services as below:

- OAuth2.0
    - Douban
    - Facebook
    - Tencent
    - Weibo
- OAuth1.0
    - Twitter

Creating a custom provider require only few lines code, for OAuth2 sites:

```
namespace YourNamespace;

class Foursquare extends \Eva\EvaOAuth\OAuth2\Providers\AbstractProvider
{
    protected $authorizeUrl = 'https://foursquare.com/oauth2/authorize';
    protected $accessTokenUrl = 'https://foursquare.com/oauth2/access_token';
}
```

Then register to service and create instance:

```
use Eva\EvaOAuth\Service;
Service::registerProvider('foursquare', 'YourNamespace\Foursquare');
$service = new Service('foursquare', [
    'key' => 'Foursquare App ID',
    'secret' => 'Foursquare App Secret',
    'callback' => 'http://somecallback/'
]);
```

Storage
-------

[](#storage)

In OAuth1.0 workflow, we need to store request token somewhere, and use request token exchange for access token.

EvaOAuth use [Doctrine\\Cache](https://github.com/doctrine/cache) as storage layer. If no configuration, default storage layer use file system to save data, default path is EvaOAuth/tmp.

Feel free to change file storage path before `Service` start:

```
Service::setStorage(new Doctrine\Common\Cache\FilesystemCache('/tmp'));
```

Or use other storage such as Memcache:

```
$storage = new \Doctrine\Common\Cache\MemcacheCache();
$storage->setMemcache(new \Memcache());
Service::setStorage($storage);
```

Events Support
--------------

[](#events-support)

EvaOAuth defined some events for easier injection which are:

- BeforeGetRequestToken: Triggered before get request token.
- BeforeAuthorize: Triggered before redirect to authorize page.
- BeforeGetAccessToken: Triggered before get access token.

For example, if we want to send an additional header before get access token:

```
$service->getEmitter()->on('beforeGetAccessToken', function(\Eva\EvaOAuth\Events\BeforeGetAccessToken $event) {
    $event->getRequest()->addHeader('foo', 'bar');
});
```

Implementation Specification
----------------------------

[](#implementation-specification)

EvaOAuth based on amazing http client library [Guzzle](https://github.com/guzzle/guzzle), use fully OOP to describe OAuth specification.

Refer wiki for details:

- [OAuth1.0](https://github.com/AlloVince/EvaOAuth/wiki/OAuth1.0-Specification-Implementation)
- [OAuth2.0](https://github.com/AlloVince/EvaOAuth/wiki/OAuth2.0-Specification-Implementation)

Debug and Logging
-----------------

[](#debug-and-logging)

Enable debug mode will log all requests &amp; responses.

```
$service->debug('/tmp/access.log');
```

Make sure PHP script have permission to write log path.

API References
--------------

[](#api-references)

Run `phpdoc` will generate API references under `docs/`.

[![](https://camo.githubusercontent.com/1b55b28c2751e4af337edc8cf04213fe05f8d9357b33f7b1e1f2de3656ec4e4d/68747470733a2f2f61766e70632e636f6d2f7374617469632f696d616765732f74656c656772616d2e706e67)](https://camo.githubusercontent.com/1b55b28c2751e4af337edc8cf04213fe05f8d9357b33f7b1e1f2de3656ec4e4d/68747470733a2f2f61766e70632e636f6d2f7374617469632f696d616765732f74656c656772616d2e706e67)

[Join My Telegram Group](https://t.me/joinchat/HKvcQAw2kqASoYfxiSrIbA)

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~85 days

Recently: every ~43 days

Total

6

Last Release

3856d ago

Major Versions

0.1.0 → 1.0.02015-04-30

PHP version history (2 changes)0.1.0PHP &gt;=5.3.3

1.0.0PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/96ac93f6fefdba56f6eca41f249433b9e937a3969ce6aab3624bff9d1e894e1d?d=identicon)[AlloVince](/maintainers/AlloVince)

---

Top Contributors

[![AlloVince](https://avatars.githubusercontent.com/u/176019?v=4)](https://github.com/AlloVince "AlloVince (59 commits)")

### Embed Badge

![Health badge](/badges/allovince-evaoauth/health.svg)

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

###  Alternatives

[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[descope/descope-php

Descope SDK for PHP

3814.0k](/packages/descope-descope-php)[egroupware/openid

EGroupware OpenID Connect / OAuth2 server

1226.8k2](/packages/egroupware-openid)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

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