PHPackages                             macfly/yii2-oauth2-server - 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. macfly/yii2-oauth2-server

AbandonedArchivedYii2-extension[Authentication &amp; Authorization](/categories/authentication)

macfly/yii2-oauth2-server
=========================

Wrapper for filsh yii2-oauth2-server provide authorize, token, user controller

0.2.1(8y ago)62.4k2[1 issues](https://github.com/marty-macfly/yii2-oauth2-server/issues)MITPHP

Since Feb 28Pushed 8y ago1 watchersCompare

[ Source](https://github.com/marty-macfly/yii2-oauth2-server)[ Packagist](https://packagist.org/packages/macfly/yii2-oauth2-server)[ Docs](https://github.com/macfly/yii2-oauth2-server)[ RSS](/packages/macfly-yii2-oauth2-server/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (13)Used By (0)

yii2-oauth2-server
==================

[](#yii2-oauth2-server)

A wrapper for [Filsh/yii2-oauth2server](https://github.com/Filsh/yii2-oauth2-server) which implement an [OAuth2 Server](https://github.com/bshaffer/oauth2-server-php)

Add missing code that make it easy to use with social network aware user module like the one from [dektrium/yii2-user](https://github.com/dektrium/yii2-user), you can use the [macfly/yii2-authclient-oauth2](https://github.com/Marty-Macfly/yii2-authclient-oauth2) which work with it out off the box.

Add controller:

- [Authorize](http://bshaffer.github.io/oauth2-server-php-docs/controllers/authorize/)
- [Token](http://bshaffer.github.io/oauth2-server-php-docs/controllers/token/)
- User (Provide user information id, username, e-mail, ...)

> /!\\ with version 2.0.13 of the Yii framework there is [an issue with Filsh/yii2-oauth2server](https://github.com/Filsh/yii2-oauth2-server/issues/134), you can fix it by updated your `composer.json` with the following

```
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/Marty-Macfly/yii2-oauth2-server-1"
        }
    ],

...

    "require": {

...

        "filsh/yii2-oauth2-server": "2.0.2.x-dev",

...

    },

...
```

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist macfly/yii2-oauth2-server "*"

```

or add

```
"macfly/yii2-oauth2-server": "*"
```

to the require section of your composer.json.

To use this extension, simply add the following code in your application configuration as a new module:

```
'modules'=>[
    //other modules .....
    'oauth2' => [
        'class' => 'macfly\oauth2server\Module',
        'tokenParamName' => 'accessToken',
        'tokenAccessLifetime' => 3600 * 24, // Default token lifetime
        'userModel' => 'app\models\User',
        'userAttributes' => [ // List of user attributes you want to provide through the /oauth2/user api call
            'id',
            'username',
            'email',
        ],
    ]
    // yii2-oauth2-server is using the kartik\datecontrol\Module so you should define the configuration of the module
    // See more details at http://demos.krajee.com/datecontrol
    'datecontrol' =>  [
        'class'             => 'kartik\datecontrol\Module',
        'ajaxConversion'    => true,
        'autoWidget'        => true,
        'saveTimezone'      => 'UTC',
    ],
],
```

Can be usefull to enable in requet component the [json parser ](http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html#enabling-json-input) and [pretty url](http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html#using-pretty-urls).

Also, extend `app\models\User` - user model - implementing the interface `\OAuth2\Storage\UserCredentialsInterface`, so the oauth2 credentials data stored in user table.

You should implement (for convenience a trait is provide):

- findIdentityByAccessToken()
- checkUserCredentials()
- getUserDetails()
- getAuthKey()
- getOauthClient() mapping of one user to one oauth client.

You can extend the model if you prefer it (please, remember to update the config files) :

```
use Yii;

class User extends app\models\User implements \OAuth2\Storage\UserCredentialsInterface
{
	use \macfly\oauth2server\traits\Oauth2User;
}

```

The next step you should run migration

```
yii migrate --migrationPath=@vendor/macfly/yii2-oauth2-server/src/migrations
```

this migration create the oauth2 database scheme and insert test user credentials `testclient:testpass` for `http://127.0.0.1:8888/user/security/auth?authclient=oauth2`

Usage
-----

[](#usage)

List of available actions
=========================

[](#list-of-available-actions)

- **/oauth2/authorize**: Session verification from a browser
- **/oauth2/token**: Get token
- **/oauth2/user**: Get user information

You can see the filsh documentation to use token ()

Admin interface
---------------

[](#admin-interface)

Manage client credentials

- **/oauth2/clients**

CRUD operations

- **/oauth2/clients/index**
- **/oauth2/clients/create**
- **/oauth2/clients/update**
- **/oauth2/clients/delete**

Manage access token

- **/oauth2/accesstokens**

CRUD operations

- **/oauth2/accesstokens/index**
- **/oauth2/accesstokens/create**
- **/oauth2/accesstokens/update**
- **/oauth2/accesstokens/delete**

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~24 days

Recently: every ~33 days

Total

12

Last Release

3095d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/74924cc29f67eef7ca7640876dd3462974466ea683f8d059c70a33b3087d7230?d=identicon)[Macfly](/maintainers/Macfly)

---

Top Contributors

[![marty-macfly](https://avatars.githubusercontent.com/u/12715929?v=4)](https://github.com/marty-macfly "marty-macfly (3 commits)")[![phucnguyenvn](https://avatars.githubusercontent.com/u/19264169?v=4)](https://github.com/phucnguyenvn "phucnguyenvn (1 commits)")

---

Tags

oauthoauth2extensionmoduleyii

### Embed Badge

![Health badge](/badges/macfly-yii2-oauth2-server/health.svg)

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

###  Alternatives

[filsh/yii2-oauth2-server

OAuth2 Server for PHP

331523.9k12](/packages/filsh-yii2-oauth2-server)[budyaga/yii2-users

Module for manage users and their rights with the support of registration through social services and assigned to each user more than one social service.

409.1k](/packages/budyaga-yii2-users)[chervand/yii2-oauth2-server

OAuth 2.0 server for Yii 2.0 with MAC tokens support.

1524.2k1](/packages/chervand-yii2-oauth2-server)[lowbase/yii2-user

Yii2 user module

131.5k2](/packages/lowbase-yii2-user)

PHPackages © 2026

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