{"id":151933,"date":"2022-01-11T09:29:03","date_gmt":"2022-01-11T09:29:03","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/gs-jwt-auth-and-otp-varification\/"},"modified":"2022-01-13T07:09:29","modified_gmt":"2022-01-13T07:09:29","slug":"gs-jwt-auth-and-otp-varification","status":"publish","type":"plugin","link":"https:\/\/wol.wordpress.org\/plugins\/gs-jwt-auth-and-otp-varification\/","author":15932442,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.0.0","stable_tag":"1.0.0","tested":"5.8.13","requires":"4.2","requires_php":"5.3.0","requires_plugins":"","header_name":"GS JWT auth and OTP varification","header_author":"Gaurav Sharma","header_description":"This is GS JWT auth and OTP varification plugin","assets_banners_color":"c7d7c9","last_updated":"2022-01-13 07:09:29","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"","header_author_uri":"","rating":0,"author_block_rating":0,"active_installs":10,"downloads":1065,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","changelog"],"tags":{"1.0.0":{"tag":"1.0.0","author":"gauravin213","date":"2022-01-13 07:09:29"},"1.2.0":{"tag":"1.2.0","author":"gauravin213","date":"2022-01-13 07:05:18"}},"upgrade_notice":[],"ratings":[],"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":2656993,"resolution":"128x128","location":"assets","locale":""},"icon-256x256.png":{"filename":"icon-256x256.png","revision":2656993,"resolution":"256x256","location":"assets","locale":""},"icon.svg":{"filename":"icon.svg","revision":2656993,"resolution":false,"location":"assets","locale":false}},"assets_banners":{"banner-1544x500-rtl.png":{"filename":"banner-1544x500-rtl.png","revision":2656993,"resolution":"1544x500","location":"assets","locale":""},"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":2656993,"resolution":"1544x500","location":"assets","locale":""},"banner-772x250-rtl.png":{"filename":"banner-772x250-rtl.png","revision":2656993,"resolution":"772x250","location":"assets","locale":""},"banner-772x250.png":{"filename":"banner-772x250.png","revision":2656993,"resolution":"772x250","location":"assets","locale":""}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0","1.2.0"],"block_files":[],"assets_screenshots":{"screenshot-1.png":{"filename":"screenshot-1.png","revision":2655697,"resolution":"1","location":"assets","locale":""},"screenshot-2.png":{"filename":"screenshot-2.png","revision":2655697,"resolution":"2","location":"assets","locale":""},"screenshot-3.png":{"filename":"screenshot-3.png","revision":2655697,"resolution":"3","location":"assets","locale":""}},"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[38852,38851,9210,2300,38850],"plugin_category":[],"plugin_contributors":[206662],"plugin_business_model":[],"class_list":["post-151933","plugin","type-plugin","status-publish","hentry","plugin_tags-json-web-authentication","plugin_tags-jwt","plugin_tags-otp","plugin_tags-wp-api","plugin_tags-wp-json","plugin_contributors-gauravin213","plugin_committers-gauravin213"],"banners":{"banner":"https:\/\/ps.w.org\/gs-jwt-auth-and-otp-varification\/assets\/banner-772x250.png?rev=2656993","banner_2x":"https:\/\/ps.w.org\/gs-jwt-auth-and-otp-varification\/assets\/banner-1544x500.png?rev=2656993","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":"https:\/\/ps.w.org\/gs-jwt-auth-and-otp-varification\/assets\/icon.svg?rev=2656993","icon":"https:\/\/ps.w.org\/gs-jwt-auth-and-otp-varification\/assets\/icon.svg?rev=2656993","icon_2x":false,"generated":false},"screenshots":[{"src":"https:\/\/ps.w.org\/gs-jwt-auth-and-otp-varification\/assets\/screenshot-1.png?rev=2655697","caption":""},{"src":"https:\/\/ps.w.org\/gs-jwt-auth-and-otp-varification\/assets\/screenshot-2.png?rev=2655697","caption":""},{"src":"https:\/\/ps.w.org\/gs-jwt-auth-and-otp-varification\/assets\/screenshot-3.png?rev=2655697","caption":""}],"raw_content":"<!--section=description-->\n<p>Extends the WP REST API using JSON Web Tokens as an authentication method.\nGS JWT plugin provides to encode and decode JSON Web Tokens (JWT), conforming to RFC 7519.<\/p>\n\n<p>GET OTP and send notification by mail or SMS service<\/p>\n\n<p><strong>Support and Requests please in Github:<\/strong> https:\/\/github.com\/gauravin213\/gs-jwt<\/p>\n\n<h3>REQUIREMENTS<\/h3>\n\n<h3>PHP<\/h3>\n\n<p><strong>Minimum PHP version: 5.3.0<\/strong><\/p>\n\n<h3>PHP HTTP Authorization Header enable<\/h3>\n\n<p>Most of the shared hosting has disabled the <strong>HTTP Authorization Header<\/strong> by default.<\/p>\n\n<p>To enable this option you'll need to edit your <strong>.htaccess<\/strong> file adding the following<\/p>\n\n<pre><code>RewriteEngine on\nRewriteCond %{HTTP:Authorization} ^(.*)\nRewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]\n<\/code><\/pre>\n\n<h4>WPENGINE<\/h4>\n\n<p>To enable this option you'll need to edit your <strong>.htaccess<\/strong> file adding the following<\/p>\n\n<pre><code>SetEnvIf Authorization \"(.*)\" HTTP_AUTHORIZATION=$1\n<\/code><\/pre>\n\n<h4>CONFIGURATION<\/h4>\n\n<p>The JWT needs to Add constant in the wp-confige.php file<\/p>\n\n<pre><code>define( 'GS_WP_JWT_SECRET_KEY', 'your-top-secret-key' );\ndefine( 'GS_WP_JWT_ALGO', 'HS256' );\ndefine( 'GS_WP_JWT_EXPIRY', (60 * 60) ); \/\/seconds * minuts\ndefine( 'GS_WP_OTP_EXPIRY', 10);  \/\/minuts\n<\/code><\/pre>\n\n<h3>Namespace and Endpoints<\/h3>\n\n<p>When the plugin is activated, a new namespace is added<\/p>\n\n<pre><code>\/gs-jwt\/v1\n<\/code><\/pre>\n\n<p>Also, two new endpoints are added to this namespace<\/p>\n\n<p>Endpoint | HTTP Verb<\/p>\n\n<p><em>\/wp-json\/gs-jwt\/v1\/login<\/em> | POST<\/p>\n\n<p><em>\/wp-json\/gs-jwt\/v1\/token\/validate<\/em> | POST<\/p>\n\n<p><em>\/wp-json\/gs-jwt\/v1\/get-otp<\/em> | POST<\/p>\n\n<p><em>\/wp-json\/gs-jwt\/v1\/verify-otp<\/em> | POST<\/p>\n\n<p><em>\/wp-json\/gs-jwt\/v1\/register_user<\/em> | POST<\/p>\n\n<p><em>\/wp-json\/gs-jwt\/v1\/register_userbymobile<\/em> | POST<\/p>\n\n<h3>USAGE<\/h3>\n\n<ol>\n<li>Get JSON web token<\/li>\n<\/ol>\n\n<h4>Request method:<\/h4>\n\n<pre><code>POST \/wp-json\/gs-jwt\/v1\/login\n\nBody{\n    \"username\": \"enter username\",\n    \"password\": \"enter password\"\n}\n<\/code><\/pre>\n\n<h4>Reponse<\/h4>\n\n<pre><code>{\n    \"data\": {\n        \"id\": \"1\",\n        \"user_login\": \"admin\",\n        \"user_pass\": null,\n        \"user_nicename\": \"admin\",\n        \"user_email\": \"example@gmail.com\",\n        \"user_url\": \"\",\n        \"user_registered\": \"2020-08-11 07:35:37\",\n        \"user_activation_key\": \"\",\n        \"user_status\": \"0\",\n        \"display_name\": \"admin\",\n        \"roles\": [\n            \"administrator\"\n        ],\n        \"token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjFcL3dvcmRwcmVzcyIsImlhdCI6MTY0MTk3MDIwNSwibmJmIjoxNjQxOTcwMjA1LCJleHAiOjE2NDE5NzM4MDUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.gRF_aNsmhQ8kqXYdKbm6dIA7zTlhcCU-e_cpP9pQDyM\"\n    }\n}\n<\/code><\/pre>\n\n<ol>\n<li>Validate JSON web token<\/li>\n<\/ol>\n\n<h4>Request method:<\/h4>\n\n<pre><code>POST \/wp-json\/gs-jwt\/v1\/token\/validate\n\nMake a POST request sending the Authorization header\nAuthorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjFcL3dvcmRwcmVzcyIsImlhdCI6MTY0MTk3MDIwNSwibmJmIjoxNjQxOTcwMjA1LCJleHAiOjE2NDE5NzM4MDUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.gRF_aNsmhQ8kqXYdKbm6dIA7zTlhcCU-e_cpP9pQDyM\n<\/code><\/pre>\n\n<h4>Reponse<\/h4>\n\n<pre><code>{\n    \"code\": \"jwt_auth_valid_token\",\n    \"data\": {\n        \"status\": 200\n    }\n}\n<\/code><\/pre>\n\n<ol>\n<li>Get otp by billing mobile number<\/li>\n<\/ol>\n\n<h4>Request method:<\/h4>\n\n<pre><code>POST \/wp-json\/gs-jwt\/v1\/get-otp\n\nBody{\n    \"mobile\": \"enter mobile number\"\n}\n<\/code><\/pre>\n\n<h4>Reponse<\/h4>\n\n<pre><code>{\n    \"data\": {\n        \"otp\": 249225,\n        \"message\": \"SUCCESS\",\n        \"otp_use_staus\": \"0\",\n        \"notification\": {\n            \"mail_send_status\": 0,\n            \"sms_send_status\": 0\n        }\n    }\n}\n<\/code><\/pre>\n\n<ol>\n<li>Verify otp and mobile number to login <\/li>\n<\/ol>\n\n<h4>Request method:<\/h4>\n\n<pre><code>POST \/wp-json\/gs-jwt\/v1\/verify-otp\n\nBody{\n    \"otp\": \"enter otp\",\n    \"mobile\": \"enter mobile number\"\n}\n<\/code><\/pre>\n\n<h4>Reponse<\/h4>\n\n<pre><code>{\n    \"data\": {\n        \"id\": \"1\",\n        \"user_login\": \"admin\",\n        \"user_pass\": null,\n        \"user_nicename\": \"admin\",\n        \"user_email\": \"example@gmail.com\",\n        \"user_url\": \"\",\n        \"user_registered\": \"2020-08-11 07:35:37\",\n        \"user_activation_key\": \"\",\n        \"user_status\": \"0\",\n        \"display_name\": \"admin\",\n        \"roles\": [\n            \"administrator\"\n        ],\n        \"token\": \"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjFcL3dvcmRwcmVzcyIsImlhdCI6MTY0MTk3MDIwNSwibmJmIjoxNjQxOTcwMjA1LCJleHAiOjE2NDE5NzM4MDUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.gRF_aNsmhQ8kqXYdKbm6dIA7zTlhcCU-e_cpP9pQDyM\"\n    }\n}\n<\/code><\/pre>\n\n<ol>\n<li>Register user<\/li>\n<\/ol>\n\n<h4>Request method:<\/h4>\n\n<pre><code>POST \/wp-json\/gs-jwt\/v1\/register_user\n\nBody{\n    \"username\": \"example\",\n    \"password\": \"example@123\",\n    \"email\": \"example@gmail.com\",\n    \"mobile\": \"1122336699\"\n}\n<\/code><\/pre>\n\n<h4>Reponse<\/h4>\n\n<pre><code>{\n    \"data\": {\n        \"id\": 29,\n        \"user_login\": \"example\",\n        \"user_pass\": null,\n        \"user_nicename\": \"example\",\n        \"user_email\": \"example@gmail.com\",\n        \"user_url\": \"\",\n        \"user_registered\": \"2022-01-12 07:45:29\",\n        \"user_activation_key\": \"\",\n        \"user_status\": \"0\",\n        \"display_name\": \"example\",\n        \"roles\": [\n            \"customer\"\n        ],\n        \"billing_phone\": \"1122336699\"\n    },\n    \"code\": 200,\n    \"message\": \"Registration was Successful\"\n}\n<\/code><\/pre>\n\n<ol>\n<li>Register user by mobile number<\/li>\n<\/ol>\n\n<h4>Request method:<\/h4>\n\n<pre><code>POST \/wp-json\/gs-jwt\/v1\/register_userbymobile\n\nBody{\n    \"mobile\": \"1122336699\"\n}\n<\/code><\/pre>\n\n<h4>Reponse<\/h4>\n\n<pre><code>{\n    \"data\": {\n        \"id\": 32,\n        \"user_login\": \"1144556638\",\n        \"user_nicename\": \"1144556638\",\n        \"user_registered\": \"2022-01-13 06:29:30\",\n        \"display_name\": \"1144556638\",\n        \"roles\": [\n            \"customer\"\n        ],\n        \"billing_phone\": \"1144556638\"\n    },\n    \"code\": 200,\n    \"message\": \"Registration was Successful\"\n}\n<\/code><\/pre>\n\n<h4>Sample add SMS and email notification<\/h4>\n\n<pre><code>\/*\n* Send notification \n* Default mail_send_status = 0, sms_send_status = 0\n*\/\nfunction gs_wp_jwt_send_notification_fun( $data, $user_id, $otp, $mobile ) {\n\n  \/\/Write mail send code here\n  $from = get_option('admin_email');\n  $to = get_user_meta($user_id, 'billing_email', true);\n  $subject = \"OTP Verification\";\n  $message = \"OTP number: {$opt} will expire in 10 min\";\n  $headers = \"From: \".$from;\n  $result = wp_mail( $to, $subject, $message, $headers);\n\n  if ($result) { \n\n    $data['mail_send_status'] = 1;\n\n  } \/\/end mail send\n\n\n  \/\/Write sms send api code here\n  \/*if ($sms_send_status) { \n\n    $data['sms_send_status'] = 1;\n\n  } \/\/ens sms send*\/\n\n  return $data;\n}\nadd_filter( 'gs_wp_jwt_send_notification', 'gs_wp_jwt_send_notification_fun', 10, 4 );\n<\/code><\/pre>\n\n<!--section=changelog-->\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>jwt jsonwebtoken encoding user_id.<\/li>\n<li>added new endpoint validate token.<\/li>\n<li>added new endpoint register user.<\/li>\n<\/ul>\n\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>added new endpoint register_userbymobile.<\/li>\n<\/ul>","raw_excerpt":"Extends the WP REST API using JSON Web Tokens as an authentication method.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wol.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/151933","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wol.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wol.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wol.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=151933"}],"author":[{"embeddable":true,"href":"https:\/\/wol.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/gauravin213"}],"wp:attachment":[{"href":"https:\/\/wol.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=151933"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wol.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=151933"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wol.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=151933"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wol.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=151933"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wol.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=151933"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wol.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=151933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}