Find the token folder in the generated PHP API
The token.php configuration file stores all the settings for your JWT token, including the expiration datetime and issuer.
The Generate.php file is used to create a token when the "Token Generation" endpoint is called with a valid username and password.
The `Validatetoken.php` file is used to validate the token for each request.
Open generate.php file (I am using VS code but you can open in normal notepad also)
To implement bcrypt encryption, we need to update this part of the code that currently uses MD5 encryption.
Validate if the hash stored in the database matches the hash of the user-provided input.
Let's examine the changes needed on the SQL query side.
Open the "object" folder. This folder contains all the database operations for each table.
Open the file corresponding to the table that stores user data. In my case, it's the `users` table, so I have a `users.php` file in my "object" folder.
Search for login_validation function
Here we are selecting by username and password.
Passing 2 parameters. Lets change it to get by only username.
Removed => AND t.password=?
Removed
Save the file, and you’re done implementing bcrypt encryption. Now, let's test it in Postman.
Collection for the generated API (Check the postman tutorial how to get this collection in postman)
Endpoint to generate token
Provide your username & password
Click "Send"
Token generated successfully
Click on View Environment Settings
Token will be automatically set for futher api calls in postman.
In Postman, you can obtain the code for the same API call in various programming languages.
jQuery sample code for generating token.
You successfully completed the guide!