yii restful api 认证问题

1.使用yii 的restful api 接口认证传递正确的access-token验证一直无法通过图片描述,配置文件配置图片描述,API的behavior配置如下图片描述,现在验证optional以外的方法需要传递access-token进行验证,传递了正确的access-token的值,还是一直提示401,麻烦有人知道是什么原因吗,谢谢

阅读 3.1k
1 个回答

在 user 里面添加

    /**
     * @inheritdoc
     */
    public static function findIdentityByAccessToken($token, $type = null)
    {
                //if ($type == '')
        // throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
        //return static::findOne(['access_token'=>$token , 'status' => self::STATUS_ACTIVE],>;
        return static::find()
        ->where(['access_token'=>$token , 'status' => self::STATUS_ACTIVE])
        ->andWhere(['>','expire_at',time()]) 
        ->one();
        // throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
    }
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题