Title: Validation API Rest with Header Auth
Last modified: January 23, 2020

---

# Validation API Rest with Header Auth

 *  Resolved [Cesar Balzer](https://wordpress.org/support/users/cesarebalzer/)
 * (@cesarebalzer)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/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_function` with 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)

 *  Plugin Support [fevered – a11n](https://wordpress.org/support/users/fevered/)
 * (@fevered)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/validation-api-rest-with-header-auth/#post-12362971)
 * Hey there,
 * This is a fairly complex development topic. I’m going to leave it open for a 
   bit to see if anyone is able to chime in to help you out.
 * I can also recommend the following places for more development-oriented questions:
    1. WooCommerce Slack Community: [https://woocommerce.com/community-slack/](https://woocommerce.com/community-slack/)
    2. Advanced WooCommerce group on Facebook: [https://www.facebook.com/groups/advanced.woocommerce/](https://www.facebook.com/groups/advanced.woocommerce/)
 *  [Austin M – a11n](https://wordpress.org/support/users/apmwebdev/)
 * (@apmwebdev)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/validation-api-rest-with-header-auth/#post-12387226)
 * We haven’t heard back from you in a while, so I’m going to mark this as resolved.
   Feel free to start a new thread if you have any further questions!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Validation API Rest with Header Auth’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [API REST](https://wordpress.org/support/topic-tag/api-rest/)
 * [validation](https://wordpress.org/support/topic-tag/validation/)

 * 2 replies
 * 3 participants
 * Last reply from: [Austin M – a11n](https://wordpress.org/support/users/apmwebdev/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/validation-api-rest-with-header-auth/#post-12387226)
 * Status: resolved