H
H
hobu4ok912017-02-12 09:21:52
Yii
hobu4ok91, 2017-02-12 09:21:52

How to set up rest authorization on yii2 hosting?

Description of the error:
1. We go to the site and log in. The token and other info are stored in the localstore.
2. In Angular, we set up a header to be sent with each request: "Authorization: Bearer token_name".
3. In yii2, in the rest controller, we specify the behavior:

public function behaviors()
    {
        $behaviors = parent::behaviors();
        $behaviors['authenticator'] = [
            'class' => HttpBearerAuth::className(),
            'only' => ['create'],
        ];
        return $behaviors;
    }

4. We send a request to the action "create"
And the error 401, unauthorization comes.
The most important thing is that everything works on my local openserver apache.
Hosting is running nginx and getting 401 errors

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2017-02-12
@R0dger

Add a line
to nginx section
location ~ \.php$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question