Validation API Rest with Header Auth
-
I created an endpoint and i’m sending a post from an external url to my endpoint
myurl.com/wp-json/my_plugin/v3/my_functionwith header authentication (Username = CK and Password = CS), when I receive the parameters in my callback, how to validate the CK and CS, creating a function that queries the database? or is there any other way to validate this information?add_action( 'rest_api_init', function () { register_rest_route( 'my_plugin/v3/', 'my_function', array( 'methods' => 'POST', 'callback' => 'my_callback' )); });function my_callback(){ $usr = $_SERVER[ 'PHP_AUTH_USER' ]; $pwd = $_SERVER[ 'PHP_AUTH_PW' ]; //validate logic: //hook, action or database verification?? // execute my custom action... }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Validation API Rest with Header Auth’ is closed to new replies.