Sorry, you are not allowed to create posts as this user - Auth issue
See original GitHub issueMy “app”:
#!/bin/env node
var WPAPI = require('wpapi');
var myusername = 'xxx';
var mypassword = 'xxx';
//var wp = new WPAPI({ endpoint: 'http://site.org:8080/wp-json', username:myusername, password:mypassword });
//
var api = WPAPI.discover( 'http://site.org:8080' ).then(function( site ) {
return site.auth({
username: myusername,
password: mypassword
});
});
api.then(function (wp) {
wp.posts().create({
title: 'Your Post Title',
content: 'Your post content',
status: 'publish'
}).then(function( response ) {
console.log( response.id );
}).catch (function(e) {
console.log(e);
});
});
Gives me:
{ code: 'rest_cannot_create',
message: 'Sorry, you are not allowed to create posts as this user.',
data: { status: 401 } }
Issue Analytics
- State:
- Created 6 years ago
- Comments:10
Top Results From Across the Web
Creating a Post , via REST API: 401 Sorry, you are not allowed ...
I am working on creating an app, using this app I want to create a custom POST in user's WordPress account. I am...
Read more >401 : Sorry, you are not allowed to create posts as this user #349
the account I am using is the Administrator and I have WP BASIC Auth (https://github.com/wokamoto/wp-basic-auth) plugin installed. { "data": { " ...
Read more >Sorry, you are not allowed to create posts as this user using ...
i have added the following code to htaccess and add plugin (JSON Basic Authentication) then it start working.
Read more >rest_cannot_create Sorry, you are not allowed to create posts ...
Following is the issue: { code: rest_cannot_create, message: Sorry, you are not allowed to create posts as this user., data: { status: 401...
Read more >How to Fix "Sorry, You Are Not Allowed to Access This Page"
In this post, we'll dig into the “Sorry, you are not allowed to access this page” error and what causes it to occur....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was also having the same issue even after installing and activating the Basic Auth Plugin from https://wordpress.org/plugins/wp-basic-auth/#installation. It worked after installing it from https://github.com/WP-API/Basic-Auth
There doesn’t appear to be anything wrong with your code; are you sure you have the Basic Authentication plugin installed & activated? Only cookie authentication is enabled by default, other authentication schemes require a specific plugin to be installed.
If you’ve already got that running and you still encounter this issue write back here and I’ll do what I can to help troubleshoot.