Страница 1 из 1

HttpBearerAuth \yii\rest\Controller

Добавлено: 2021.01.24, 19:31
hovhannes_ab
Как смогу понять , почему Bearer Auth локально работает (MAMP SERVER) , а на сервере не работает ? В чем может быть проблема ?

Код:

Код: Выделить всё

 public function behaviors()
    {
        $behaviors = parent::behaviors();

        $behaviors['contentNegotiator'] = [
            'class' => ContentNegotiator::className(),
            'formats' => [
                'application/json' => Response::FORMAT_JSON,

            ],
        ];
        $behaviors['authenticator'] = [
            'class' => CompositeAuth::className(),
            'authMethods' => [
                HttpBearerAuth::className()
            ]
        ];
        return $behaviors;
    }
}
----------------------------------------------------

Код: Выделить всё


 Код ответа:
    {
    "name": "Unauthorized",
    "message": "Your request was made with invalid credentials.",
    "code": 0,
    "status": 401,
    "type": "yii\\web\\UnauthorizedHttpException"

.