Authentication Yii2 oauth2客户端\u凭证令牌身份验证

Authentication Yii2 oauth2客户端\u凭证令牌身份验证,authentication,oauth-2.0,yii2,yii2-validation,Authentication,Oauth 2.0,Yii2,Yii2 Validation,我使用Filsh/yii2-oauth2-server 我可以使用$\u pos使用客户端令牌访问我的API 在控制器中: if (!isset($_post['token'])){ //exeption } else{ token = $_post('token'); } if ((Accesstokens::isAccessTokenValid($token))) { // do some thing. } in my Accesstokens model : public static

我使用Filsh/yii2-oauth2-server

我可以使用$\u pos使用客户端令牌访问我的API

在控制器中:

if (!isset($_post['token'])){
//exeption
}
else{ 
token = $_post('token');
}
if ((Accesstokens::isAccessTokenValid($token))) {
// do some thing.
}
in my Accesstokens model :

public static function isAccessTokenValid($token)
    {
        if (empty($token)) {
            return false;
        }
        $query = (new \yii\db\Query())
            ->select(['access_token','expires'])
            ->from('oauth_access_tokens')
            ->where(['access_token' => $token])
//            ->limit(10)
            ->one();
        if (empty($query)) {
            return false;
        }
        $expire = $query['expires'];
        return $expire > date('Y-m-d h:i:s');
    } 
如果我使用password(user_credential)令牌,我可以使用以下方式实现承载身份验证:

public function behaviors()
    {
        return ArrayHelper::merge(parent::behaviors(), [
            'authenticator' => [
                'class' => CompositeAuth::className(),
                'authMethods' => [
                    ['class' => HttpBearerAuth::className()],
                    ['class' => QueryParamAuth::className(), 'tokenParam' => 'accessToken'],
                ]
            ],
            'exceptionFilter' => [
                'class' => ErrorToExceptionFilter::className()
            ],
        ]);
    }
但这种方法是使用authenticate user中的user表,而不是oauth_client表来验证没有用户的客户端

如何仅基于客户端表而不基于用户表对令牌进行身份验证

Request:
GET http://myapi.com/api/www/index.php/oauth2/token
grand_type = client_credentials
client_id = id1
client_secret = secret1

Response:
"access_token": "thisistheccesstoken",
"expires_in": 31104000,
"token_type": "Bearer",
"scope": "default"

Request:
GET http://myapi.com/api/www/index.php/oauth2/v1/get/frogs
HEADER Authorization: Bearer thisistheaccesstoken

Response:
all the frogs
如何使用:头授权:承载?有人能帮忙吗