I am implementing Rest API in yii2. I want to authenticate the user using access token. I have referred various SO answers as follows
But I m not clear, which authentication method I should use and how I will get user identity.
I have created findIdentityByAccessToken()
method in my user identity class as suggested in Yii2 Rest guide .
Below is the behaviour
implemented in my controller
public function behaviors() {
$behaviors = parent::behaviors();
$behaviors['authenticator'] = [
'class' => HttpBasicAuth::className(),
'except' => ['login','forgot-password']
];
return $behaviors;
}
now, how I will get the user identity inside my controller action? As far as i know, access token will be set from the web service inside request header.
Note : I am using Yii2 advanced app please help me.