Dieser Artikel erklärt, wie Sie als Administrator/in einen Webservice aufsetzen. Jede/r Nutzer/in erhält einen einmaligen Sicherheitsschlüssel (Token), um auf den Service zuzugreifen.


Webservices aktivieren

  1. Gehen Sie auf die Seite Einstellungen > Website-Administration > Zusatzoptionen.
  2. Markieren Sie die Checkbox Webservices und klicken Sie auf den Button Änderungen speichern.

Hinweis: Aus Sicherheitsgründen sollten Sie Webservices nur dann aktivieren, wenn Sie sie wirklich nutzen wollen.

Protokolle aktivieren

Normalerweise bestimmen die externen Applikationen, welches Protokoll aktiviert werden muss.

  1. Gehen Sie auf die Seite [[Einstellungen-Block|Einstellungen > Website-Administration > Plugins > Webservices > Protokolle verwalten.
  2. Aktivieren Sie die Protokolle (SOAP, REST, XMLRPC, AMF, ...) nach Bedarf.

Dokumentation zu Webservices aktivieren

Markieren Sie auf der Seite [[Einstellungen-Block|Einstellungen > Website-Administration > Plugins > Webservices > Protokolle verwalten die Checkbox Dokumentation zu Webservices. Dann erscheint auf Seite Sicherheitsschlüssel ein Link Dokumentation angezeigt, der zur nutzerspezifischen Webservice-Dokumentation führt. Diese Option ist für Webservice-Client-Entwickler/innen nützlich.

Einen Service anlegen

Wenn keiner der vorhandenen Webservices Ihren Anforderungen genügt, können Sie einen eigenen Webservice anlegen If none of the pre-build web services match your needs, you can create a custom service i.e. select which of the standard web service functions are available via that service.

You can enable only the specific functions that you need to expose, so not compromising on security.

Datei:Create a service.jpg
Creating a service
  1. Access Settings > Site administration > Plugins > Web services > External services
  2. Click Add new custom service
    • 'Authorised users only' - If enabled, you will need to select the authorised users manually. Otherwise all users with appropriate permissions are allowed
    • 'Required capability' - If enabled, any user accessing the web service will be checked against this selected capability. (This is just an additional optional security layer.)
  3. Enter a name and check Enabled
  4. Click the button 'Add service'

Funktionen zu einem Service hinzufügen

Datei:Select a web service function.jpg
Adding functions to the service

Your service is currently empty and doesn't do anything. Web service functions need to be added. Your choice will be dictated by what you allow the external application to do. For this example, select 'Create group'.

  1. Click 'Add functions' link
  2. Select 'create group' function and click the 'Add functions' button

You should be back to the service functions list. 'Required capabilities' are indicated for each function. Users need the required capabilities to run a function. The function descriptions in the API Documentation can also give you more information about the required capabilities (Settings > Site administration > Plugins > Web services > API Documentation).

Rechte

The final step is to grant appropriate permissions. The following capabilities should be allowed:

Once done, the web service should be set up. Users should be able to obtain a personal security key.

Alternative Einstellungen

Authorise only specific users

  1. Settings > Site Administration > Plugins > Web services > External Services
  2. Select Authorised users link (the service must have been set as Authorised users only in the Edit link)
  3. Select some users and click Add

Moodle indicates if some capabilities need to be assigned to an authorised user. Moreover if you click on the authorised user fullname, you can set up some specific options: IP restriction and Valid until.

Ein Token erzeugen

This feature allows you to create a token for specific user. It can be useful if a user doesn't have the moodle/create:token capability. This is also the only way to create a token for an administrator. For security reason, tokens are not automatically generated in the administrator security keys page.

  1. Settings > Site Administration > Plugins > Web services > Manage tokens
  2. Click on Add
  3. Select the created user and service
  4. Click on Saves changes

As you created a token for this user, you do not need to assign "moodle/webservice:createtoken" to him/her. Finally, note that, as for authorised users, you can also set IP restriction and Valid until on a token.

Siehe auch