Yii2 - Installing Filsh OAuth2 Server

I am currently trying to install the Yii2 extension to implement the OAuth2 server ( https://github.com/Filsh/yii2-oauth2-server ). However, I continue to work with the error below:

Error page

Does anyone have an idea on how to install this extension. I followed the instructions, but this error was not mentioned.

+5
source share
4 answers

Satya is right. You need to configure the oauth2 module as described in the repo description :

 'oauth2' => [ 'class' => 'filsh\yii2\oauth2server\Module', 'options' => [ 'token_param_name' => 'accessToken', 'access_lifetime' => 3600 * 24 ], 'storageMap' => [ 'user_credentials' => 'common\models\User' ], 'grantTypes' => [ 'client_credentials' => [ 'class' => 'OAuth2\GrantType\ClientCredentials', 'allow_public_clients' => false ], 'user_credentials' => [ 'class' => 'OAuth2\GrantType\UserCredentials' ], 'refresh_token' => [ 'class' => 'OAuth2\GrantType\RefreshToken', 'always_issue_new_refresh_token' => true ] ], ] 

I successfully configured this extension and created the Yii2 Rest API template with OAuth2 server https://github.com/ikaras/yii2-oauth2-rest-template - feel free to use. Also this code contains some demo data (usage examples) and scopes support for controllers.

+3
source

Add the command "oauth2" in the "modules" section of config / main.php. He can work

+1
source

Use this configuration in the confin / main.php file in the modules section.

 'oauth2' => [ 'class' => 'filsh\yii2\oauth2server\Module', 'tokenParamName' => 'token', 'tokenAccessLifetime' => '100800', // Expiry Time 'storageMap' => [ 'user_credentials' => 'common\models\User', // This Should be your model name ], 'grantTypes' => [ 'client_credentials' => [ 'class' => 'OAuth2\GrantType\ClientCredentials', 'allow_public_clients' => false, ], 'user_credentials' => [ 'class' => 'OAuth2\GrantType\UserCredentials', ], 'refresh_token' => [ 'class' => 'OAuth2\GrantType\RefreshToken', 'always_issue_new_refresh_token' => true, 'refresh_token_lifetime' => '100800', ], ], 

];

0
source

The found solution is my-self on scope issue, maybe it will be useful for someone marked ** in config:

 'modules' => [ 'oauth2' => [ 'class' => 'filsh\yii2\oauth2server\Module', 'tokenParamName' => 'accessToken', 'tokenAccessLifetime' => 3600 * 24, 'storageMap' => [ 'client_credentials' => 'app\models\User', 'user_credentials' => 'app\models\User', **'scope' => 'app\models\User',** ], 'grantTypes' => [ 'client_credentials' => [ 'class' => '\OAuth2\GrantType\ClientCredentials', 'allow_public_clients' => false, 'always_issue_new_refresh_token' => true ], 'user_credentials' => [ 'class' => 'OAuth2\GrantType\UserCredentials', ], 'refresh_token' => [ 'class' => 'OAuth2\GrantType\RefreshToken', 'always_issue_new_refresh_token' => true ] ] ] ], 
0
source

Source: https://habr.com/ru/post/1212511/


All Articles