Moodle core_user_create_users Access control exception

Moodle core_user_create_users Access control exception

by Huy Đức Lê -
Number of replies: 2

Can anyone tell me how to use the example code here ? 

https://github.com/moodlehq/sample-ws-clients/blob/master/JAVA-REST/RestJsonMoodleClient.java


When I use my admin token from manage token, it always give:

{"exception":"webservice_access_exception","errorcode":"accessexception","message":"Access control exception"}

The tutorials I found did not solve the problem. I currently use moodle cloud.

Thanks in advance

Average of ratings: -
In reply to Huy Đức Lê

Re: Moodle core_user_create_users Access control exception

by Dorel Manolescu -
Picture of Plugin developers

Hi

For the web-service user in moodle did you assign the right permissions to create users:

require_capability('moodle/user:create', $context);
Let us know!

Regards

In reply to Huy Đức Lê

Re: Moodle core_user_create_users Access control exception

by Bob Belz -

I had this error "Access control exception". Enabling REST in Moodle administration for the role user is in worked for me

Site administration > Users > Define roles > the role in question, for example Student > Edit > Use REST protocol, webservice/rest:use > check it

There are also SOAP, XML-RPC protocols there to try enabling. 

Also maybe this role needs to get set (on the same page) to

"Context types where this role may be assigned" > System

"Create a web service token for mobile access", moodle/webservice:createmobiletoken -> checked too if this error is on mobile app.