April 2020
Intermediate to advanced
716 pages
18h 55m
English
Next, we will try to access a protected API without signing in first. A GET request to read any one of the users will return a 401 Unauthorized error, such as in the following example. Here, a GET request to /api/users/5a1c7ead1a692aa19c3e7b33 returns a 401 error:

To make this request return a successful response with user details, a valid authorization token needs to be provided in the request header. We can generate a valid token by successfully calling the sign-in request.