Rest API authentication with Headless WordPress

WordPress provides built-in support for authenticating the incoming request to its restful API, which is handy.

Rest API authentication with Headless WordPress
Photo by Onur Binay / Unsplash

Application Password

reference

  1. generate set an application password
  2. use it for authentication
    http://localhost:8888/wp-json/wp/v2/posts/1
    using Basic Authentication
  • Username: YOUR_LOGIN_USERNAME
  • Password: APPLICATION_PASSWORD

On Local Development

reference
define WP_ENVIRONMENT_TYPE to enable Application Password in a local environment without HTTPS

define( 'WP_ENVIRONMENT_TYPE', 'local' );