Authentication

There are three kinds of authentication:

  • HTTP Basic Auth (the HttpBasicAuth class): This method uses the WWW-Authenticate HTTP header to send the username and password for every request
  • Query parameter (the QueryParamAuth class): This method uses an access token passed as query parameter in the API URL
  • OAuth 2 (the HttpBearerAuth class): This method uses an access token that is obtained by the consumer from an authorization server and sent to the API server via HTTP bearer tokens

Yii supports all the methods mentioned, but we can also easily create a new one.

To enable authentication, follow these steps:

  1. Configure the user application component in the configuration, setting enableSession to false in order to make user authentication status ...

Get Yii2 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.