Error 401 while trying to create wordpress user from n8n - Authorization failed

Hello there, i’m facing an issue since a few days that I can’t seem to resolve; I’ve installed the lasted n8n desktop version on w10 and I’m using a local server running on xampp for my wordpress website. I can successfully connect to the wordpress account using my credentials. The issue happen whenever I try to do something related to a creation; When I’m doing a POST - UPDATE, or even a GET, it works fine BUT anything related to a creation like creating an user or a post wont work and will give me an error message saying “ERROR: Authorization failed - please check your credentials”.

My credentials are correct since n8n can connect to my WP website, and the wordpress URL that i’m using is http://localhost/wordpress/

Any help would be gladly appreciated, thanks :slight_smile:

{“message”:“401 - {"code":"rest_cannot_create","message":"Désolé, vous n’avez pas l’autorisation de créer des contenus sous cet identifiant.","data":{"status":401}}”,“name”:“Error”,“stack”:“Error: Request failed with status code 401\n at createError (C:\Users\Fianso\AppData\Local\Programs\n8n\resources\app\node_modules\axios\lib\core\createError.js:16:15)\n at settle (C:\Users\Fianso\AppData\Local\Programs\n8n\resources\app\node_modules\axios\lib\core\settle.js:17:12)\n at IncomingMessage.handleStreamEnd (C:\Users\Fianso\AppData\Local\Programs\n8n\resources\app\node_modules\axios\lib\adapters\http.js:269:11)\n at IncomingMessage.emit (node:events:406:35)\n at IncomingMessage.emit (node:domain:470:12)\n at endReadableNT (node:internal/streams/readable:1331:12)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)”}

NodeApiError: Authorization failed - please check your credentials
    at Object.requestWithAuthentication (C:\Users\Fianso\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-core\dist\src\NodeExecuteFunctions.js:953:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.execute (C:\Users\Fianso\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-nodes-base\dist\nodes\Wordpress\Wordpress.node.js:149:40)
    at async Workflow.runNode (C:\Users\Fianso\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-workflow\dist\src\Workflow.js:645:28)
    at async C:\Users\Fianso\AppData\Local\Programs\n8n\resources\app\node_modules\n8n-core\dist\src\WorkflowExecute.js:562:53

Hi @Marty_McFly, welcome to the community :tada:

I am very sorry to hear you’re having trouble. I just tried creating a new user through the Wordpress node and didn’t have any trouble here:

This was with an app password from Wordpress for my existing account rather than a regular user password:

With the 401 error coming from Wordpress, could it be that your current Wordpress user (the one you have authenticated with n8n) doesn’t have suitable permissions? Or you have an active plugin preventing this from working?

Perhaps you can check these details and share your workflow so we can check which operation exactly you are running here (make sure to set a dummy password for the new user instead of a real one when sharing your workflow)?

1 Like

Hello there @MutedJam, ty for your welcoming me

The application passwords option wasn’t accessible at first since the website was running on a local environment and therefore, not on HTTPS. It absolutely wanted HTTPS first but even when creating an SSL certificate for XAMPP on localhost, n8n wouldnt let me connect to the website anymore.

Turned out I was able to create an app password after putting this snippet define( 'WP_ENVIRONMENT_TYPE', 'local' ); into both the wp-config.php and wp-config-sample.php files AND restricting to only using http protocol in the credential.

Thank you very much for your help :slight_smile:

1 Like

Ah sweet, I didn’t even think about HTTPS being the problem where, but that makes sense. Woocommerce also limits the API functionality a lot when using HTTP.

Thanks so much for confirming and for sharing your solution!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.