Hello, I am trying to access nextcloud (user information, storage, login status etc) using OAUTH2
I have registered my Client (a php-website on the same server for now) in Nextcloud, and my Client works so far, that I get an access_token.
Now the problem is, when I use this access_token to try and get any information out of nextcloud, I keep getting statuscode 997, current user is not logged in http-status 401…
$url = “https://127.0.0.1/nextcloud/ocs/v1.php/cloud/users?format=json&client_id=xxx&client_secret=xxx”;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
“Accept: application/json”,
“Authorization: Bearer {”.$token."}",
“OCS-APIRequest: true”
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, false);
Any ideas what I’m doing wrong/how to fix this? Thanks a lot…
PS: I’m using the newest version of NC on a local apache server.