Implementing an RESTful API Authentication using tokens (Yii/Yii2)

后端 未结 3 1690
失恋的感觉
失恋的感觉 2021-01-30 00:05

I am building an API in Yii 1.x which will be used with a mobile application. Part of the process involves a login (with a username and password) using the following JSON reques

3条回答
  •  情书的邮戳
    2021-01-30 00:13

    By this time probably you switched to Yii2, and for future reference, the cleanest solution would be to use included classes for RESTful APIs, or one can implement them in any framework.

    Source: HttpBearerAuth.php

    The advantages are explained fully in this article, but to summarise, it's better to use your solution with request headers, since GET parameters might be saved in logs and Basic Auth password can be easily intercepted if you don't use SSL (you should!)

提交回复
热议问题