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

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

pinfirestudios/yii2-oauth2-authorization-server
===============================================

OAuth2 Authorization Server for Yii2. Fork of abandoned filsh/yii2-oauth2-server package

v2.1.4(6y ago)0231[1 issues](https://github.com/pinfirestudios/yii2-oauth2-authorization-server/issues)[1 PRs](https://github.com/pinfirestudios/yii2-oauth2-authorization-server/pulls)MITPHP

Since Dec 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/pinfirestudios/yii2-oauth2-authorization-server)[ Packagist](https://packagist.org/packages/pinfirestudios/yii2-oauth2-authorization-server)[ Docs](https://github.com/pinfirestudios/yii2-oauth2-authorization-server)[ RSS](/packages/pinfirestudios-yii2-oauth2-authorization-server/feed)WikiDiscussions master Synced yesterday

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

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

[](#yii2-oauth2-authorization-server)

This is a fork of [filsh/yii2-oauth2-server](https://github.org/filsh/yii2-oauth2-server) with latest patches from various forks thereof.
-----------------------------------------------------------------------------------------------------------------------------------------

[](#this-is-a-fork-of-filshyii2-oauth2-server-with-latest-patches-from-various-forks-thereof)

A wrapper for implementing an OAuth2 Server()

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

[](#installation)

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

Either run

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

```

or add

```
"pinirestudios/yii2-oauth2-authorization-server": "~2.1"
```

to the require section of your composer.json.

To use this extension, simply add the following code in your application configuration:

```
'bootstrap' => ['oauth2'],
'modules' => [
    'oauth2' => [
        'class' => 'filsh\yii2\oauth2server\Module',
        'tokenParamName' => 'accessToken',
        'tokenAccessLifetime' => 3600 * 24,
        'storageMap' => [
            'user_credentials' => 'common\models\User',
        ],
        'grantTypes' => [
            'user_credentials' => [
                'class' => 'OAuth2\GrantType\UserCredentials',
            ],
            'refresh_token' => [
                'class' => 'OAuth2\GrantType\RefreshToken',
                'always_issue_new_refresh_token' => true
            ]
        ]
    ],
```

If you want to get Json Web Token (JWT) instead of convetional token, you will need to set `'useJwtToken' => true` in module and then define two more configurations: `'public_key' => 'app\storage\PublicKeyStorage'` which is the class that implements [PublickKeyInterface](https://github.com/bshaffer/oauth2-server-php/blob/develop/src/OAuth2/Storage/PublicKeyInterface.php) and `'access_token' => 'app\storage\JwtAccessToken'` which implements [JwtAccessTokenInterface.php](https://github.com/bshaffer/oauth2-server-php/blob/develop/src/OAuth2/Storage/JwtAccessTokenInterface.php)

For Oauth2 base library provides the default [access\_token](https://github.com/bshaffer/oauth2-server-php/blob/develop/src/OAuth2/Storage/JwtAccessToken.php) which works great except that it tries to save the token in the database. So I decided to inherit from it and override the part that tries to save (token size is too big and crashes with VARCHAR(40) in the database.

TL;DR, here are the sample classes **access\_token**

```
