Javascript/node:
const SITE = '...';
const auth = { username: '....', password: '....' };
const token = Buffer.from(`${auth.username}:${auth.password}`, 'utf8').toString('base64');
const wpFetch = (url, meta) => fetch(
`${SITE}/wp-json/wp/v2${url}`,
{
...meta,
headers: { Authorization: `Basic ${token}` },
},
);
(async () => {
try {
const fetched = await wpFetch(
'/posts',
{
method: 'POST',
body: JSON.stringify({
title: 'Hello World',
content: 'content',
status: 'publish',
}),
},
);
const json = await fetched.json();
console.log(json);
} catch (e) {
console.error(e);
}
})();
I’m getting Sorry, you are not allowed to create posts as this user.
, which I think is the generic WP error message. The password above was generated with “Application Password”.
Just wondering if anyone knows why this isn’t working on bedrock, could it be the different password encryption scheme?