-
Download the repository as a ZIP file. Under
/admin/tool/installaddon/index.php, install the plugin from the ZIP file. (Alternatively, extract the ZIP file under thelocal/jwttomoodletokendirectory.) Configure it, for example, by settingspub_key_discovery_urltohttps://login.microsoftonline.com/<TENANT_ID>/discovery/v2.0/keys,pub_key_cache_file_pathto/local/jwttomoodletoken/config/pubkey.json,read_jwt_attributetoemail,preferred_username, orunique_name,matched_user_attributetousername,email, oridnumber, andmatch_auth_typetoshibbolethoroidc. You can always navigate to/admin/settings.php?section=local_jwttomoodletokento change the config. -
Under
/admin/roles/manage.php, create a new role (for instance,jwttomoodletokenpluginaccess). UnderContext types where this role may be assigned, checkSystem. Allow thelocal/jwttomoodletoken:usewscapability for this newly created role. (It is already defined indb/access.php, so it should just appear.) -
Under
/user/editadvanced.php?id=-1, create a new user (for instancejwttomoodletoken webserviceaccess). Underauthentication method, choosemanual account. Under/admin/roles/assign.php?contextid=1, assign the system role created above to the newly created user. -
Under
/admin/webservice/tokens.php, create a new token for the user created above. Choose thelocal_jwttomoodletoken_webserviceservice from the dropdown. (It is already defined indb/services.php, so it should just appear.) Make sure it does not have an expiry date. Optionally, set an IP restriction. -
The
/admin/index.phppage might perform a system check, and ask you to "upgrade the DB". This usually happens after some installation/uninstallation. It should not encounter any errors. -
Make sure the "Moodle mobile web services" are enabled, under
/admin/settings.php?section=externalservices, and the REST protocol is enabled under/admin/settings.php?section=webserviceprotocols
Try to request a Moodle token for a given access token:
/webservice/rest/server.php?wstoken=<WS_TOKEN>&wsfunction=local_jwttomoodletoken_gettoken&accesstoken=
<ACCESS_TOKEN>&moodlewsrestformat=json