5.15-Yii-QueryParamAuth.php-Use QueryAuthparam in REST API can not get a query parameters

What steps will reproduce the problem?

        public function behaviors()
    {
        $behaviors = parent::behaviors();
        
        $behaviors['authenticator'] = [
        'class' => QueryParamAuth::className(),
        'except' => ['login','logout']
        ];

        return $behaviors;
    }

What is the expected result?

When I pass the query parameter in the url , such as

http://backend.test/commons?access-token=x2qwgZPIQTW6Et-SQnDgdly6BJHJttGx

Then I will get the reponse from the controller instead of

"data": {
"name": "Unauthorized",
"message": "Your request was made with invalid credentials.",
"code": 0,
"status": 401,
"type": "yii\web\UnauthorizedHttpException"
}

What do you get instead?

use request->get print in QueryParamAuth.php. There is

/**
     * {@inheritdoc}
     */
    public function authenticate($user, $request, $response)
    {
        print_r($request);
        print_r($request->get());
        exit;

[_url:yii\web\Request:private] => /commons?access-token=x2qwgZPIQTW6Et-SQnDgdly6BJHJttGx

Array
(
[/commons] =>
)

Additional info

Q A
Yii version This is Yii version 2.0.18-dev.
PHP version PHP 7.1
Operating system Windows 7

This issue had been fixed.

#15305 (comment)

Apache - .htaccess

Replace RewriteRule ^(.*)$ /index.php?/$1 [L] by RewriteRule . index.php

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteRule . index.php
5.15-Yii-QueryParamAuth.php-Use QueryAuthparam in REST API can not get a query parameters_第1张图片
empty-access-token.png
5.15-Yii-QueryParamAuth.php-Use QueryAuthparam in REST API can not get a query parameters_第2张图片
with-access-token.png

你可能感兴趣的:(5.15-Yii-QueryParamAuth.php-Use QueryAuthparam in REST API can not get a query parameters)