Web Services Moodle 2.9.1 --任何Web服务函数都会出现“访问控制异常”

nfs0ujit  于 11个月前  发布在  其他
关注(0)|答案(6)|浏览(137)

根据各种指南,我设法完成了以下工作:

  • 使用REST API(包括“core_user_create_users”函数)设置外部服务,
  • 设置一个用户帐户,并将其分配为允许使用我设置的REST API服务,
  • 为web服务用户定义了一个角色,原型为“经过身份验证的用户”,上下文为“系统”,
  • 将角色设置为允许“moodle/user:create”,
  • 为Web服务用户手动生成了一个没有过期的令牌。

现在,当我进入内置的Web服务测试客户端,选择在REST API上使用基于令牌的身份验证,选择“moodle_user_create_users”函数并放入令牌和详细信息时,我得到了这样的结果:

REST protocol: moodle_user_create_users
URL: [...]
'<?xml version="1.0" encoding="UTF-8" ?>
<EXCEPTION class="webservice_access_exception">
<ERRORCODE>accessexception</ERRORCODE>
<MESSAGE>Access control exception</MESSAGE>
<DEBUGINFO>Access to the function moodle_user_create_users() is not allowed.
There could be multiple reasons for this:
1. The service linked to the user token does not contain the function.
2. The service is user-restricted and the user is not listed.
3. The service is IP-restricted and the user IP is not listed.
4. The service is time-restricted and the time has expired.
5. The token is time-restricted and the time has expired.
6. The service requires a specific capability which the user does not have.
7. The function is called with username/password (no user token is sent)
and none of the services has the function to allow the user.
These settings can be found in Administration &gt; Site administration
&gt; Plugins &gt; Web services &gt; External services and Manage tokens.</DEBUGINFO>
</EXCEPTION>

字符串
我错过了什么?

xdnvmnnf

xdnvmnnf1#

尝试获取令牌抛出https://yourmoodle/login/token.php?username=username&password=pass&service=webserviceshortname。我的令牌从/admin/settings.php?section=webservicetokens也不工作,并启用功能的服务在/admin/settings.php?section=externalservices

anhgbhbe

anhgbhbe2#

我有同样的例外.然后我在管理 Jmeter 板中进行了此更改.
网站管理->移动的应用程序->移动的设置->为移动的设备启用Web服务。
把这个打开。
我的问题就是他解决的

b0zn9rqh

b0zn9rqh3#

我的回答似乎和其他人经历过的一样:Web服务测试客户端已经无可救药地崩溃了。
这是一个已知的问题,当时我在这个项目上工作,不幸的是,Moodle决定继续提供这个功能。
在可预见的未来,我建议不要浪费你的时间,甚至试图使用这个“工具”。

5ktev3wc

5ktev3wc4#

// moodle(4.1)//
我还得面对这个错误几天所以你要做的是
它需要令牌当请求通过获取课程详情->要做到这一点你的web_service需要启用首先检查你的数据库名称“mdl_externel_sservices”在那里你看到所有的服务你创建,为了获得“令牌”首先命名为“启用”的列需要更改为1,然后只有你可以获得令牌来启用这个!
网站管理->服务器-> Web服务->外部服务->选择您需要访问的服务,然后选中名为“启用”的复选框
现在要验证到数据库检查它是否被chnaged或没有!1意味着服务被启用。
现在检查请求使用 Postman 为这个网址
“http://localhost/moodle/login/token.php?service=test_ws&username=ADMIN_NAME&password=ADMIN_PASS&service=SERVICE_NAME”
它将返回“令牌”
使用此令牌请求此URL“http://localhost/moodle/webservice/rest/server. php?wstoken = TOKEN & wsfunction = core_course_get_courses(以获取课程详细信息)&moodlewsrestformat=json&options[ids][COURSE_ID]=COURSE_ID”

bn31dyow

bn31dyow5#

在Moodle管理 Jmeter 板中配置所有元素(funcions,user,role,action-role,token).
当我使用Web服务测试客户端选择“core_user_create_users”函数,而不是“moodle_user_create_users”(我忽略了为什么使用后者)时,异常没有出现在我面前,响应是OK的。

9jyewag0

9jyewag06#

尝试从以下位置启用Web服务身份验证:站点管理>插件>管理身份验证

相关问题