Ciao Stefano,
non so se hai già risolto: nel caso, leggi https://docs.moodle.org/dev/Creating_a_web_service_client#How_to_get_a_user_token per scoprire come usare login/token.php che è quello che fa al caso tuo .
Inoltre, i token possono anche essere preassegnati e gestiti direttamente in Site administration > Plugins > Web services > Manage tokens (/admin/settings.php?section=webservicetokens), ma forse questo è il meccanismo che stai già usando adesso in sviluppo.
HTH,
Matteo