Just got it working but not with this plugin. I’ll post a how to later today. Victory!
Please do Someguyagain. Can’t wait to see how you solved it.
Okay let’s start with a fresh install of WP. I’m using wp-cli found at http://wp-cli.org/
Download WP
wp core download
Setup the config file
wp core config --dbname=wp_cli --dbuser=root --dbpass=A123456
Install WP
wp core install --url=pathToYourWPDir --title=WP-CLI --admin_user=admin --admin_password=A123456 admin_email=someEmail@email.com
Now jump into the plugins dir
cd somePath/wp-content/plugins
We need to install the api server
git clone git@github.com:WP-API/WP-API.git
Now it’s time to install the Basic Auth
git clone https://github.com/WP-API/Basic-Auth.git
Go ahead and install OAuth1
git clone git@github.com:WP-API/OAuth1.git
We have to enable everything by logging into the admin dashboard.
Under plugins activate JSON REST API then JSON Basic Authentication and OAuth Server. Remember for the REST API to work you have to have Permalinks setup. I always just use Post name.
From what I’ve read you have to log out before the Basic Auth will work. Not sure if that is true or not have not tested it yet.
So for the fun stuff let’s make a log file and watch it.
touch logs.txt && watch -n 1 cat logs.txt
Open up another terminal and use curl to hit the endpoint. *Note you need to be in the same dir that you made the logs.txt
curl -s --user admin http://somePathToYourWpSite/wp-json/wp/users/me -o "logs.txt"
Type in your password and watch the magic happen.
Good luck 🙂
****Sorry “admin_email=someEmail@email.com” when installing WP should be “–admin_email=someEmail@email.com”
@someguyagain thanks for your guide! Just a clarification for future readers:
Just got it working but not with this plugin. I’ll post a how to later today. Victory!
It IS this plugin 🙂 But besides this plugin you also need the extra Basic Authentication WP-API plugin:
https://github.com/WP-API/Basic-Auth
It’s just a php file and as any other plugin you can drop it in your /wp-content/plugins folder and activate through admin panel.
So in summary, once you install and activate both plugins:
https://wordpress.org/plugins/json-rest-api/
and
https://github.com/WP-API/Basic-Auth
Basic Authentication will work out of the box (or at least that has been my experience 🙂 )
I was having the same issue with basic authentication too and my issue was of two parts.
The first was that I didn’t have Basic-Auth installed (thanks robert.giaz for that).
The second was that I’m working with a multi-site install. It appears that when you make a request to the site the user you’re authenticating needs to exist for that specific site. If they exist just at a network level or in a sibling site the authentication will fail.
@diggersworld glad it helped. It’s always good to know one’s posts might save some time to others.