Authentication and authorization with HTTP
The Fake Store API provides an endpoint for authenticating users with a username and a password. It contains a login method that accepts a username and a password as parameters and returns an authentication token. We will use the authentication token in our application to differentiate between a logged-in user and a guest.
The username and password are provided by a predefined pool of users at https://fakestoreapi.com/users.
We will explore the following authentication and authorization topics in this section:
- Authenticating with a backend API
- Authorizing users for certain features
- Authorizing HTTP requests using interceptors
Let’s get started with how to authenticate with the Fake Store API.
Authenticating with backend API
In Angular real-world applications, we usually consider authentication as an application feature. So, we will create a new Angular module that will handle authentication in our application. The module will contain...