Testing the token-based authentication

We can test this out using curl commands in the Terminal. To test the token-based authentication flow, follow these steps:

  1. Open the Terminal and generate first a base64-encoded string of email and password of the user we will need to authenticate as. You can do so using the following command in the Terminal. Replace the email with the email of the user you created previously from the browser and password with the user's password:
$ echo -n 'ankur@email.com:password' | openssl base64
  1. Running the preceding command will generate a base64-encoded version of the username and password, and now we will use this to get the token from our Vapor server by making a POST request to /tokens and pass the username ...

Get Hands-On Full-Stack Development with Swift 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.