General developer forum

Autocreate webservice token upon plugin installaion

 
Picture of v k
Autocreate webservice token upon plugin installaion
 

Hello all,

I've been developing a plugin for Moodle (current ver. 3.5.1+), which is designed to communicate with an external website. I created the Plugin's external API functions. They seem to work properly with special webservice user, service and token I've created via the moodle site administation interface manually.

I want to have a webservice user, webservice service (with the Plugin's ext functions included) and a webservice token created automatically during the Plugin's installation process (when its folder is placed in /mod and moodle site detects it on refresh). 

Is it possible?

Thank you!

 
Average of ratings: -
Picture of Darko Miletić
Re: Autocreate webservice token upon plugin installaion
Core developersParticularly helpful Moodlers

Yes. You should place your code in install.php. Take a look into structure of moodle plugin

https://docs.moodle.org/dev/Plugin_files#db.2Finstall.php


 
Average of ratings: -