Set Auth Header in cURL

If it comes to testing REST APIs, I’m a big fan of Postman. But for quick and command-line testing, I always prefer to use cURL. For developing and testing protected endpoints, we need to pass an authorization header. How can we do this with cURL?

Example of using Bearer tokens:

Example request (invalid token):

Response:

Example request (valid token):

More information about jwt tokens and authentication mechanism: