appcoder appcoder - 1 year ago 178
reST (reStructuredText) Question

REST API call for login on Yii2

I am starting to use yii2 and I am providing a

from the web app. I could not find any documentation on how to provide login functionality using yii2 REST api.
Previously in
, we used to have an action called
which takes in a username and password and authenticate it(with User model).
Is that the same approach still with
? Like in
(under the Api module) have an
method with GET request type and once authenticated successfully return
User object
(with access token for subsequent calls?) ?

Answer Source

Well, it looks like creating an actionLogin method and that takes in username and password is still the way to go on yii2 (confirmed from yii2 developers). Also, you have to either exclude the actionLogin from authentication behaviors and there are couple of ways it could be done(either through override before action and not calling authenticate method, and the other approach is to add this actionLogin method in some controller which does not describe the authentication behavior).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download