1.1 JWT Authentication Setup

For User Authentication

This plugin is required for the authentication purpose of user registration & login. After installing and activating the plugin, you have to configure some stuff. You can follow their guide or follow the steps below:

  • You have to edit your .htaccess file and add two lines of code there. You can get the file in your Cpanel > File manager > public_html > your_site directory. Now click on edit the file and add the following two lines under the RewriteEngine On line and click on Save changes at the top.

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]

Note: There are many .htaccess files in the Cpanel file manager. You have to edit the right one, or else the login/registration process in the app won’t work. So, How do you know which is the right one? You have to edit the .htaccess file from the folder where you have stored your WordPress site. Example:

a) If you have installed the site directly in the public_html directory without creating any additional folder, then you have to edit the .htaccess file from the public_html directory.

b) if you have installed the site with an additional folder, like public_html/recipehour.xyz/ then you have to edit the .htaccess file from the recipehour.xyz folder. That’s it.

  • Now, again you have to edit your wp-config.php file and add two lines of code. You will get the file in the same directory Cpanel > File manager > public_html> your_site> wp-config.php. Now click on edit the file and add the following two lines under the define( 'WP_DEBUG', false ); line.

define('JWT_AUTH_SECRET_KEY', 'your-top-secret-key');
define('JWT_AUTH_CORS_ENABLE', true);
  • After adding these two lines of code, you have to add a top-secret key in the first line of the following code. To get the code go to this url and copy the NONCE SALT key and paste it here. After this, your lines will look like in the picture below:

Now save the file. That’s it.

Last updated