Authentication
-
Hello,
Congratulations for the plugin, I’m really looking forward to seeing it in core!
My main problem is that I cannot authenticate. I’m trying to do it using PHP and curl, but I have not succeeded so far.
For example, if I try:
$username='username'; $password='password'; $url='https://example.com/wp-json/users'; $ch = curl_init(); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/json", "Accept:application/json", 'Authorization:Basic '. base64_encode($username.":".$password))); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLINFO_HEADER_OUT, true); $result=curl_exec($ch); curl_close($ch); var_dump(json_decode($result, true));
I get “Sorry, you are not allowed to list users”.
Same if I try:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$URL); curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code $result=curl_exec ($ch); curl_close ($ch); return $result;
Anybody may help please?
Thanks a lot in advance!
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Authentication’ is closed to new replies.