diff --git a/lib/class-wp-json-authentication-oauth1.php b/lib/class-wp-json-authentication-oauth1.php index 913a3f5..cf6a4fd 100644 --- a/lib/class-wp-json-authentication-oauth1.php +++ b/lib/class-wp-json-authentication-oauth1.php @@ -93,6 +93,15 @@ public function get_parameters( $require_token = true, $extra = array() ) { $params = array_merge( $_GET, $_POST ); $params = wp_unslash( $params ); + // @kosso: Check for raw POST Content-Type: application/json data (requires php://input since PHP 5.6) and then json_decode it. + if($_SERVER['CONTENT_TYPE']=='application/json'){ + $raw_post_data_params = json_decode(file_get_contents('php://input'), true); + if ( ! empty( $raw_post_data_params ) ) { + $raw_post_data_params = wp_unslash( $raw_post_data_params ); + $params = array_merge( $params, $raw_post_data_params ); + ksort($params); + } + } $header = $this->get_authorization_header(); if ( ! empty( $header ) ) { diff --git a/lib/class-wp-json-authentication.php b/lib/class-wp-json-authentication.php index 615de8b..1375644 100644 --- a/lib/class-wp-json-authentication.php +++ b/lib/class-wp-json-authentication.php @@ -42,12 +42,12 @@ public function get_consumer( $key ) { 'post_status' => 'any', 'meta_query' => array( array( - 'meta_key' => 'key', - 'meta_value' => $key, + 'key' => 'key', + 'value' => $key, ), array( - 'meta_key' => 'type', - 'meta_value' => $this->type, + 'key' => 'type', + 'value' => $this->type, ), ), ) );