Answer the question
In order to leave comments, you need to log in
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;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question