WordPress REST API JWT Authentication Method



WordPress REST API JWT Authentication Method involves the REST APIs access on validation based on the JWT (JSON Web Token), Each time a request to access the API will be made, the authentication will be done against that JWT token, and on the basis of the verification of that JWT token, the resources for that API request will be allowed to access.

Download And Installation

  • Log into your WordPress instance as an admin.
  • Go to the WordPress Dashboard -> Plugins and click on Add New.
  • Search for a WordPress REST API Authentication plugin and click on Install Now.
  • Once installed click on Activate.

WordPress REST API JWT Authentication Method:

  • Select REST API Authentication method → JWT Authentication and click on Save Configuration.
  • WordPress REST API JWT Authentication method using jwt
  • Here you would need to make two calls:
  • I : Get the JWT Token

    • To get the JWT Token, you would need to make an REST API Call to Token endpoint as below:
    • Request: POST https://<domain-name>/wp-json/api/v1/token
      Body:
      username = <wordpress username>
      password = <wordpress password>
      

    II : Send API Request

    • Once you get the JWT token, you can use it to request access to the WordPress REST APIs as shown below:
    • Request: GET https://<domain-name>/wp-json/wp/v2/posts
      
      Header: Authorization : Bearer <JWT token>
      
  • NOTE: Above token is valid for 1 hour by default. Users have to create a token each time they want to request the API access
  • Check out the developer documentation for more details.

Postman Samples:

    Follow the steps below to make REST API request using Postman:

  • Click on the Postman Samples tab in the plugin.
  • WordPress REST API JWT Authentication method postman implementation
  • A JSON file will be auto downloaded.
  • WordPress REST API JWT Authentication method postman JSON file
  • Import the downloaded JSON file into the Postman Application as shown below.
  • a) REST API Request to obtain the JWT token
    • Once you import the json file, click on the REST API request under the Collections as shown in the last figure. Replace the <wp_base_url> with your Wordpress domain in the http://<wp_base_url>/wp-json/wp/v2/posts and replace the <wordpress_username> with WordPress username and <wordpress_username> with WordPress password in the body parameters.
    • WordPress REST JWT Authentication method postman replace base url
    • Example
    • WordPress REST JWT Authentication method postman replace base url example
    • NOTE: Copy the jwt token obtained from response. It will be used in the resource API requests to authenticate.
  • b) REST API Request to obtain the actual resource
    • Once you import the json file, click on the REST API request under the Collections as shown in the last figure. Replace the <wp_base_url> with your Wordpress domain in the http://<wp_base_url>/wp-json/wp/v2/posts and replace the <jwt_token> with the jwt token copied from the response obtained after the token request.
    • WordPress REST JWT Authentication method postman replace base url actual resource
    • Example
    • WordPress REST API JWT Authentication method postman replace url actual resource

Need Help?

Mail us on oauthsupport@xecurify.com for quick guidance(via email/meeting) on your requirement and our team will help you to select the best suitable solution/plan as per your requirement.


Hello there!

Need Help? We are right here!

support
Contact miniOrange Support
success

Thanks for your inquiry.

If you dont hear from us within 24 hours, please feel free to send a follow up email to info@xecurify.com