2

I am trying to make an API request from postman to WordPress.

I get a 401 Authorization required error when I make the call, as per the screenshot below:

enter image description here

The credentials I am using are from the admin user of the site. I want to use OAuth in the future, but for testing purposes, I am trying to run a simple test with basic authentication, and move for OAuth afterward.

I do not understand if I am missing some WordPress configuration, or what is wrong here.

I have WordPress 4.9.5. I have tried going to the user details/ settings/profile to search for the API keys for the user, as per some information I found online, but I see no API related information in the admin user or other. I have tried making changes to the .htaccess file to add a line related to the Authorization, but I haven't been able to get this to work.

I am running out of options as I can't understand what I am missing...Any hints?

4

adding this rule to .htaccess solved my problem: -

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
3

I found the problem, Postman was not being very helpful with the message.

Turns out the site had http authentication, which affects the api requests, but the message was not very helpful.

Turning off http authentication fixed the issue.

2
  • How did you turn off the HTTP authentication, please? I am facing the same problem.
    – Tes3awy
    Sep 16 '19 at 8:48
  • It depends on your server configuration. It can be an .httaccess .httpasswd file or something within your webserver configuration, or different files if you're using nginx instead of apache Sep 16 '19 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.