GS JWT Authentication for WP REST API

GS JWT Authentication for WP REST API

Wordpress plugin

Install on Wordpress

App Details

Extends the WP REST API using JSON Web Tokens as an authentication method.
GS JWT plugin provides to encode and decode JSON Web Tokens (JWT), conforming to RFC 7519.

GET OTP and send notification by mail or SMS service

Support and Requests please in Github: https://github.com/gauravin213/gs-jwt

REQUIREMENTS

PHP

Minimum PHP version: 5.3.0

PHP HTTP Authorization Header enable

Most of the shared hosting has disabled the HTTP Authorization Header by default.

To enable this option you’ll need to edit your .htaccess file adding the following

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

WPENGINE

To enable this option you’ll need to edit your .htaccess file adding the following

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 

CONFIGURATION

The JWT needs to Add constant in the wp-confige.php file

define( 'GS_WP_JWT_SECRET_KEY', 'your-top-secret-key' ); define( 'GS_WP_JWT_ALGO', 'HS256' ); define( 'GS_WP_JWT_EXPIRY', (60 * 60) ); //seconds * minuts define( 'GS_WP_OTP_EXPIRY', 10); //minuts 

Namespace and Endpoints

When the plugin is activated, a new namespace is added

/gs-jwt/v1 

Also, two new endpoints are added to this namespace

Endpoint | HTTP Verb

/wp-json/gs-jwt/v1/login | POST

/wp-json/gs-jwt/v1/token/validate | POST

/wp-json/gs-jwt/v1/get-otp | POST

/wp-json/gs-jwt/v1/verify-otp | POST

/wp-json/gs-jwt/v1/register_user | POST

/wp-json/gs-jwt/v1/register_userbymobile | POST

USAGE

  1. Get JSON web token

Request method:

POST /wp-json/gs-jwt/v1/login Body{ "username": "enter username", "password": "enter password" } 

Reponse

{ "data": { "id": "1", "user_login": "admin", "user_pass": null, "user_nicename": "admin", "user_email": "[email protected]", "user_url": "", "user_registered": "2020-08-11 07:35:37", "user_activation_key": "", "user_status": "0", "display_name": "admin", "roles": [ "administrator" ], "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjFcL3dvcmRwcmVzcyIsImlhdCI6MTY0MTk3MDIwNSwibmJmIjoxNjQxOTcwMjA1LCJleHAiOjE2NDE5NzM4MDUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.gRF_aNsmhQ8kqXYdKbm6dIA7zTlhcCU-e_cpP9pQDyM" } } 
  1. Validate JSON web token

Request method:

POST /wp-json/gs-jwt/v1/token/validate Make a POST request sending the Authorization header Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjFcL3dvcmRwcmVzcyIsImlhdCI6MTY0MTk3MDIwNSwibmJmIjoxNjQxOTcwMjA1LCJleHAiOjE2NDE5NzM4MDUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.gRF_aNsmhQ8kqXYdKbm6dIA7zTlhcCU-e_cpP9pQDyM 

Reponse

{ "code": "jwt_auth_valid_token", "data": { "status": 200 } } 
  1. Get otp by billing mobile number

Request method:

POST /wp-json/gs-jwt/v1/get-otp Body{ "mobile": "enter mobile number" } 

Reponse

{ "data": { "otp": 249225, "message": "SUCCESS", "otp_use_staus": "0", "notification": { "mail_send_status": 0, "sms_send_status": 0 } } } 
  1. Verify otp and mobile number to login

Request method:

POST /wp-json/gs-jwt/v1/verify-otp Body{ "otp": "enter otp", "mobile": "enter mobile number" } 

Reponse

{ "data": { "id": "1", "user_login": "admin", "user_pass": null, "user_nicename": "admin", "user_email": "[email protected]", "user_url": "", "user_registered": "2020-08-11 07:35:37", "user_activation_key": "", "user_status": "0", "display_name": "admin", "roles": [ "administrator" ], "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjFcL3dvcmRwcmVzcyIsImlhdCI6MTY0MTk3MDIwNSwibmJmIjoxNjQxOTcwMjA1LCJleHAiOjE2NDE5NzM4MDUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.gRF_aNsmhQ8kqXYdKbm6dIA7zTlhcCU-e_cpP9pQDyM" } } 
  1. Register user

Request method:

POST /wp-json/gs-jwt/v1/register_user Body{ "username": "example", "password": "example@123", "email": "[email protected]", "mobile": "1122336699" } 

Reponse

{ "data": { "id": 29, "user_login": "example", "user_pass": null, "user_nicename": "example", "user_email": "[email protected]", "user_url": "", "user_registered": "2022-01-12 07:45:29", "user_activation_key": "", "user_status": "0", "display_name": "example", "roles": [ "customer" ], "billing_phone": "1122336699" }, "code": 200, "message": "Registration was Successful" } 
  1. Register user by mobile number

Request method:

POST /wp-json/gs-jwt/v1/register_userbymobile Body{ "mobile": "1122336699" } 

Reponse

{ "data": { "id": 32, "user_login": "1144556638", "user_nicename": "1144556638", "user_registered": "2022-01-13 06:29:30", "display_name": "1144556638", "roles": [ "customer" ], "billing_phone": "1144556638" }, "code": 200, "message": "Registration was Successful" } 

Sample add SMS and email notification

/* * Send notification * Default mail_send_status = 0, sms_send_status = 0 */ function gs_wp_jwt_send_notification_fun( $data, $user_id, $otp, $mobile ) { //Write mail send code here $from = get_option('admin_email'); $to = get_user_meta($user_id, 'billing_email', true); $subject = "OTP Verification"; $message = "OTP number: {$opt} will expire in 10 min"; $headers = "From: ".$from; $result = wp_mail( $to, $subject, $message, $headers); if ($result) { $data['mail_send_status'] = 1; } //end mail send //Write sms send api code here /*if ($sms_send_status) { $data['sms_send_status'] = 1; } //ens sms send*/ return $data; } add_filter( 'gs_wp_jwt_send_notification', 'gs_wp_jwt_send_notification_fun', 10, 4 ); 

Pricing

Starting from $0 per month.

Check Out the Image Carousel Widget

By Common Ninja

Image CarouselTry For Free!

App Info

Rating

Reviewers

No reviews

Tags

json web authentication
jwt
otp
wp-api
wp-json

Developed By

Gaurav Sharma

Quick & Easy

Find the Best Wordpress plugins for you

Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!

Testimonial

Testimonial plugins for Wordpress

Contact Form

Contact Form plugins for Wordpress

Maps

Maps plugins for Wordpress

Translation

Translation plugins for Wordpress

Chat

Chat plugins for Wordpress

Slider

Slider plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Contact

Contact plugins for Wordpress

Galleries

Galleries plugins for Wordpress

SEO

SEO plugins for Wordpress

Forms

Forms plugins for Wordpress

Comments

Comments plugins for Wordpress

Backup

Backup plugins for Wordpress

Privacy

Privacy plugins for Wordpress

Optimize

Optimize plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Comments

Comments plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Video Player

Video Player plugins for Wordpress

popup

popup plugins for Wordpress

SiteMap

SiteMap plugins for Wordpress

Payment

Payment plugins for Wordpress

Coming Soon

Coming Soon plugins for Wordpress

Inventory

Inventory plugins for Wordpress

Testimonials

Testimonials plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Membership

Membership plugins for Wordpress

Forms

Forms plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Sliders

Sliders plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Security

Security plugins for Wordpress

Ads

Ads plugins for Wordpress

Music Player

Music Player plugins for Wordpress

Countdown

Countdown plugins for Wordpress

Email Marketing

Email Marketing plugins for Wordpress

Membership

Membership plugins for Wordpress

Ecommerce

Ecommerce plugins for Wordpress

Customer Support

Customer Support plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Common Ninja Apps

Some of the best Common Ninja plugins for Wordpress

Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.

Image Carousel for Wordpress logo

Image Carousel

Showcase images with an image carousel that rotates or slides visuals, improves design, and draws attention to key content.

PayPal Donate Button for Wordpress logo

PayPal Donate Button

Make it easy for supporters to contribute using PayPal or Stripe by adding a donation button that keeps giving fast, secure, and on site.

Interactive Video Player for Wordpress logo

Interactive Video Player

Add interactive video overlays with links, product cards, and buttons that appear on top of your videos to boost engagement and guide user actions.

MP3 Player for Wordpress logo

MP3 Player

Add an MP3 Player to your website and engage visitors with music, podcasts, and spoken audio without any setup complexity.

HIPAA Compliance Forms for Wordpress logo

HIPAA Compliance Forms

Create secure HIPAA compliant forms that protect sensitive data, offer full customization, and integrate easily for safe medical information collection.

Comparison Tables for Wordpress logo

Comparison Tables

Add comparison tables to your site to help visitors evaluate features side by side, understand differences quickly, and choose the right option with confidence.

TDEE Calculator for Wordpress logo

TDEE Calculator

Create custom calculators that let visitors enter values, get results, and make confident choices that support your business.

Call Button for Wordpress logo

Call Button

Add a call button to your site so visitors can tap to start a phone call instantly, improving direct communication access.

Bluesky Feed Slider for Wordpress logo

Bluesky Feed Slider

Show Bluesky posts with a Bluesky feed slider that scrolls updates and keeps content visible while keeping visitors engaged.

News Ticker for Wordpress logo

News Ticker

Use a news ticker to display headlines and updates that highlight key information and keep users informed in real time.

Skill Flip Cards for Wordpress logo

Skill Flip Cards

Use skill flip cards to showcase your abilities in a clear, interactive format that strengthens your profile and improves your chances of getting hired.

Audio Player for Wordpress logo

Audio Player

Add a no-code audio player to your site and boost engagement with music, podcasts, and voice content effortlessly.

More plugins

plugins You Might Like

Discover Apps By Platform

Discover the best apps for your website

WordPress
Wix
Shopify
Weebly
Webflow
Joomla
PrestaShop
Shift4Shop
WebsiteX5
MODX
Opencart
NopCommerce

Common Ninja Search Engine

The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!

Multiple platforms