【问题标题】:csrf check failed in nextcloude apinextcloude api 中的 csrf 检查失败
【发布时间】:2018-06-19 06:43:34
【问题描述】:

我正在使用 php 中的 curl 请求在 nextcloude 中调用用户注册 api 但我得到以下回应。

csrf 检查失败

我的curl请求如下。

$ownAdminname=“xxxx”;
$ownAdminpassword=“xxx”;

$ownconnect="https://".$ownAdminname.":".$ownAdminpassword."@local.ngageapp.com";

$username=‘xxxx’;
$password=‘xxx’;
$url = “{$ownconnect}/ocs/v1.php/cloud/users”;
$ownCloudPOSTArray = array(‘userid’ => $username, ‘password’ => $password );
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $ownCloudPOSTArray);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $ownAdminname.":".$ownAdminpassword);
$response = curl_exec($ch);
curl_close($ch);

我需要有关此问题的帮助。提前致谢!

【问题讨论】:

    标签: php curl nextcloud


    【解决方案1】:

    来自https://docs.nextcloud.com/server/12/admin_manual/configuration_user/user_provisioning_api.html

    对 OCS 端点的所有调用都需要将 OCS-APIRequest 标头设置为 true。

    添加标题就可以了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-26
      • 1970-01-01
      • 2020-10-12
      • 2021-05-19
      • 1970-01-01
      • 1970-01-01
      • 2011-07-03
      相关资源
      最近更新 更多