PHPackages                             rowasc/yii2oauthserver - 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. rowasc/yii2oauthserver

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

rowasc/yii2oauthserver
======================

A module that implement's TheLeague's OAuth component for Yii2

1.0.3(10y ago)015MITPHP

Since Sep 6Pushed 10y agoCompare

[ Source](https://github.com/rowasc/yii2oauthserver)[ Packagist](https://packagist.org/packages/rowasc/yii2oauthserver)[ RSS](/packages/rowasc-yii2oauthserver/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (5)Used By (0)

- Copy the migration file to your own migrations directory (inside of your yii2 project) , and run the migrations. Make sure you update the client\_id and client\_secret before using it in your project, since they are not safe the way they are added in the migration!
- Edit your yii2 configuration to include the following under "components"

```
    'ResourceServerComponent'=> [
        'class' => 'rowasc\yii2oauthserver\components\ResourceServerComponent'
    ],
    'AuthServerComponent'=> [
        'class' => 'rowasc\yii2oauthserver\components\AuthServerComponent'
    ],
```

- Edit your yii2 configuration to include the following under "modules"

```
     'yii2oauthserver' => [
               'class' => '@vendor\rowasc\yii2oauthserver\Module',
     ]
```

- In your .htaccess file, allow the Authorization headers to pass, since they will be stripped most of the time witouth this line

```
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
```

- Have your base api controller extend " \\rowasc\\yii2oauthserver\\controllers\\ApiController" .
- Create an AuthorizationController, and extend \\rowasc\\yii2oauthserver\\controllers\\AuthorizationController in it.
- In your User model, extend rowasc\\yii2oauthserver\\models\\User

This will create an "/authorization/login" and a "/authorization/logout" endpoint which will allow you to get and expire bearer tokens for your api auth.

### Examples: getting a new bearer token

[](#examples-getting-a-new-bearer-token)

POST /v1/authorization/login HTTP/1.1 Host: api.yii2-starter-kit.dev Content-Type: application/json Cache-Control: no-cache Postman-Token: 7dd28588-b30d-a252-5c7e-5ecc9d1ab740

```
{
    "client_id": "client_name",
    "client_secret": "client_secret",
    "username": "webmaster",
    "password": "webmaster"
}
```

Response:

```
{
    "access_token": "ENMTcmTSgQTmwCpVbaO3AHHbhbJYgziiZzjWzWUd",
    "token_type": "Bearer",
    "expires_in": 43200
}
```

### Examples: invalidating the token so users do not have access to the api

[](#examples-invalidating-the-token-so-users-do-not-have-access-to-the-api)

POST /v1/authorization/logout HTTP/1.1 Host: api.yii2-starter-kit.dev Content-Type: application/json Authorization: Bearer ENMTcmTSgQTmwCpVbaO3AHHbhbJYgziiZzjWzWUd Cache-Control: no-cache Postman-Token: 9b86bad2-dd05-898b-5888-6047e0dd2772

```
{
    "client_id": "client_name",
    "client_secret": "client_secret",
    "username": "webmaster",
    "password": "webmaster"
}
```

Response:

```
{
  "status": true
}
```

### Help wanted:

[](#help-wanted)

#### This project is in need of better tests.

[](#this-project-is-in-need-of-better-tests)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity66

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 ~14 days

Total

4

Last Release

3865d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/db1d09fdb337fabf5bd899b2c7e853ea7152f2fdd353211174dbacc77cbc8766?d=identicon)[rowasc](/maintainers/rowasc)

---

Top Contributors

[![rowasc](https://avatars.githubusercontent.com/u/2434401?v=4)](https://github.com/rowasc "rowasc (10 commits)")

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/rowasc-yii2oauthserver/health.svg)

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

###  Alternatives

[jeremy379/laravel-openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

55342.3k2](/packages/jeremy379-laravel-openid-connect)[nl.idaas/openid-server

OpenID Connect server for PHP

47129.2k1](/packages/nlidaas-openid-server)[simplesamlphp/simplesamlphp-module-oidc

A SimpleSAMLphp module adding support for the OpenID Connect protocol

5016.9k1](/packages/simplesamlphp-simplesamlphp-module-oidc)[chervand/yii2-oauth2-server

OAuth 2.0 server for Yii 2.0 with MAC tokens support.

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

A Yii2 Oauth 2 and OpenID Connect server based on thephpleague/oauth2-server

1911.8k](/packages/rhertogh-yii2-oauth2-server)

PHPackages © 2026

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