-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Usage Example #5
Comments
Hello, I also have some questions about the use of this module. How are you supposed to use the authentication? |
I also have same question. Anyone here who have an answer yet? |
I have also a problem with implementation of this extension. |
@jvalecillos @anders-akero this is implementation of OAuth2. So I guess you have to read what it says of it |
i don't undestand with this statement |
I guess I will have to write simple tutorial! |
@mtangoo is this correct? |
I will put together a very simple tutorial this night! |
+1 |
+1 Need some more examples, it took me a few hours to work out what I needed to do to get this working. |
+1 |
Not sure how useful it is but have a look at this http://www.yiiframework.com/forum/index.php/topic/60293-oauth2-server/page__pid__281355#entry281355 |
+1 here is what i found out '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
]
]
] this snippet should be included inside application configuration, that is on the same level as $config = [
...
'components' => [...],
'params' => ....
'oauth2' => ...
...
]; and another thing is my vendor folder, there is no Then, when I try to get the access token: curl -v -i -H "Accept:application/json" -H "Content-Type:application/json" "http://api.jenjobs.local/oauth2/token" -XPOST -d '{"grant_type":"password","username":"xxx","password":"xxx","client_id":"testclient","client_secret":"testpass"}' the result {"access_token":"0a9e3d64ad9efe228abca5a846d74e4a8b2a0ea5","expires_in":86400,"token_type":"Bearer","scope":null |
Here is my public static function findIdentityByAccessToken($token, $type = null) {
$retval = null;
$oauthServer = Yii::$app->getModule('oauth2')->getServer();
$oauthRequest = Yii::$app->getModule('oauth2')->getRequest();
$oauthServer->verifyResourceRequest($oauthRequest);
$token = $oauthServer->getAccessTokenData($oauthRequest);
$retval = self::findOne($token['user_id']);
return $retval;
} Inspired by You should change Maybe it helps. |
:( This version is so buggy... I should not do any fixes in external library! (But I have to :/) |
and share back a fix |
Please, be guided by the latest readme in the master branch. |
Hello, thanks for the good work on this module it looks cool and professional :)
Can you please update the Usage example as it is not very clear.
I added the behaviors on my SiteController and seems to work,
but can not manage to send a proper requests I always get this error:
"You are requesting with an invalid credential."
Is there anything special about the controller or the params to make it work ?
The text was updated successfully, but these errors were encountered: