I have an endpoint that receives a url
, username
, application password
and blogPost
.
I then base64 encode the username and password, attach the blogPost
data in the body of the request and send it off.
The request makes it to the other server, but I get a 401 "incorrect_password" response:
{
"code": "incorrect_password",
"message": "The provided password is an invalid application password.",
"data": {
"status": 401
}
}
I have tested this with Postman and get the exact same response. I have also attempted authenticating on 2 different sites, with all pluggins disabled. Both site are host on Kinsta using nginx.
My endpoint code:
$auth = base64_encode($cc_agent_un.':'.$cc_agent_ap);
$wp_request_headers = array(
'Authorization' => 'Basic '.$auth,
'Content-Type' => 'application/json'
);
$body = array(
'title' => $blogTitle,
'content' => $blogContent,
'status' => 'publish'
);
$result = wp_remote_post($url, [
'headers' => $wp_request_headers,
'body' => $body
]);
// if request is successful, return success message. If not, return error message from wp_remote_post
if (is_wp_error($result)) {
return [
'status' => 'Blog Post Failed: '
];
} else {
return [
'status' => 'Blog Has Been Successfully Posted'
];
}