I've setup a basic auth for quick testing a site.
$headers = array (
'Authorization' => 'Basic ' . base64_encode( 'admin' . ':' . 'Str0nGP@$$w0rd' ),
);
$url = rest_url( 'wp/v2/posts/1' );
$data = array(
'title' => 'Hello Gaia'
);
$response = wp_remote_post( $url, array (
'method' => 'POST',
'headers' => $headers,
'body' => $data
) );
var_dump($response['body']);
Pretty much the example the official docs provide. But I get an error all the time.
{"code":"rest_cannot_edit","message":"Sorry, you are not allowed to edit this post.","data":{"status":401}}
So I tried a different site (site with minimal plugins, twenty*theme) on a different server (apache and nginx).
Same thing.
Am I doing something wrong? Is basic auth still supported or outdated?
I know there are other ways to authenticate.
I'm not asking about that.
I want too know why basic auth doesn't work.