How to enable web services for an external system

Jump to: navigation, search

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.

Moodle 2.0

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.

First steps

  1. Enable web service feature
  2. Enable a protocol
  3. Enable the web service function documentation
  4. Create a service however you must check Authorised users only
  5. 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

Authorised users link.jpg
Authorised user selection page.jpg
 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

Create token.jpg
 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.

The token.jpg
The external system administrator can connect into Moodle and see the token into his/her 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).

See also