How to enable web services for an external system
Note: You are currently viewing documentation for Moodle 1.9. Up-to-date documentation for the latest stable version is available here: How to enable web services for an external system.
This document explains how an administrator can set up a web service for one external system. One token will be generated during this setup. The external system administrator will enter the token into the external system. The external system users do not need to enter any personal security key.
- Enable web service feature
- Enable a protocol
- Enable the web service function documentation
- Create a service however you must check Authorised users only
- Add functions to the service
Create a user for the external system
Settings block > Site Administration > Users > Accounts > Add a new user
Complete the fields and select Update profile operation
Authorise the user
Settings block > Site Administration > Plugins > Web services > External Services Select Authorised users link Select the created user and click Add
As you can see in the second screen capture, Moodle indicates if some capabilities need to be assigned to an authorised user. Moreover if you click on the authorised user you can setup some specific options: IP restriction and Valid until.
Create a token
Settings block > Site Administration > Plugins > Web services > Manage tokens Click on Add Select the created user and service Click on Saves changes
Enable capabilities for the user
The last step, and the trickiest, is to grant the right permission to the external system user. It would need the following capabilities:
- "webservice/rest:use, webservice/soap:use, webservice/xmlrpc:use, webservice/amf:use" matching the enabled protocols.
- the required capabilities by the web service functions. These required capabilities are listed when you add a function to the service.
As you previously created a token for the external system user, you do not need to assign "moodle/webservice:createtoken" to it. For more information about roles and capabilities, read the Manage roles documentation.
security keys page. Or you can directly tell him is token if you don't want to communicate his/her web login/password (in this case think to give him/her a copy of the web service function documentation located on his/her security keys page).