Keep getting 401 error from WordPress on AWS Lightsail

I’ve found a solution. The WordPress made from AWS Lightsail instance image is bitnami WordPress. And the bitnami WordPress is disabled Basic Authentication as default. So it needs some modification on /opt/bitnami/apps/WordPress/conf/httpd-app.conf to enable Basic Authentication. This modification is adding 3 lines below. RewriteEngine on RewriteCond %{HTTP:Authorization} ^(.*) RewriteRule ^(.*) – [E=HTTP_AUTHORIZATION:%1] The httpd-app.conf ended … Read more

Can we access the REST request parameters from within the permission_callback to enforce a 401 by returning false?

I’ve created a reduced test case that demonstrates that what you want to do is achievable: add_action( ‘rest_api_init’, function() { register_rest_route( ‘wpse/343039’, ‘route’, [ ‘methods’ => [ ‘POST’ ], ‘permission_callback’ => function( WP_REST_Request $request ) { if ( ‘1’ == $request->get_param( ‘param’ ) ) { return true; } else { return false; } }, ‘callback’ … Read more

Add media with WP-Rest-API v2 II

I suspect based on an answer at StackOverflow that something like this would work: base64credentials=”…… ” curl –request POST \ –url “http://www.yoursite.com/wp-json/wp/v2/media” \ –header “cache-control: no-cache” \ –header “content-disposition: attachment; filename=tmp” \ –header “authorization: Basic $base64credentials” \ –header “content-type: image/png” \ –data-binary “@/home/web/tmp.png” \ –location This should use tmp.png to create and upload a brand … Read more

How to upload image to wordpress from external page

Just to make sure: You have a local environment, without WooCommerce, from which you want to create a product in your WooCommerce WordPress site, and make sure that the images you provide are uploaded to your WordPress site. 1. Install library Make sure that you in your local environment have installed the WooCommerce REST API … Read more

Updata Metadata WP Rest API

Two things need to be changed 1 – wishlistPost.metadata.wishlist_array which is the metadata returns an object with a string inside, not an array. var wishlist_array = wishlistPost.metadata.wishlist_array[0]; //Get current string wishlist_array += postID + “,”; //Concat new ID to the current string 2 – JSON.stringify(wishlist_array) is not needed as stated above wishlist_array is a string … Read more

OAuth signature does not match

I was facing a similar issue when trying to use Client-CLI with OAuth 1.0a plugin, however I found a solution here on the official repository. In the file lib/class-wp-json-authentication-oauth1.php on line 524, change the following code: $base_request_uri = rawurlencode( get_home_url( null, parse_url( $_SERVER[‘REQUEST_URI’], PHP_URL_PATH ), ‘http’ ) ); to: $home_url_path = parse_url(get_home_url (null,”,’http’), PHP_URL_PATH ); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)