ok, I was wrong I just needed to give permission to the webservice (advanced parameters -> webservice). I was able to do it using the WebserviceKey class that has the method
setPermissionForAccount, and passing it a parameter containing the permissions extracted from a json file.
Here is my install function:
public function install()
{
$keyId = $this->getKeyId();
$wsKey = new WebserviceKey($keyId ? $keyId : null);
$wsKey->active = true;
$wsKey->description = self::KEY_DESCRIPTION_MARKER;
do {
$wsKey->key = $this->generateKey(self::KEY_LENGTH);
} while (WebserviceKey::keyExists($wsKey->key));
$wsKey->add();
$permissions_file = "../modules/".$this->name."/data/permissions.json";
$jsonPermissions = file_get_contents($permissions_file); //TODO controlli sul file
$permissions_to_set = json_decode($jsonPermissions,true);
$wsKey->setPermissionForAccount($wsKey->id,$permissions_to_set);
$configuration = new stdClass();
$configuration->soap_key = $wsKey->key;
Configuration::updateValue('XXX_CONFIGURATION', json_encode($configuration));
return parent::install() &&
$this->registerHook('actionAdminControllerSetMedia') &&
$this->registerHook('displayBackOfficeHeader');
}
in the permissions.json we have:
{
"messages": {
"GET": "on"
},
"order_carriers": {
"GET": "on",
"PUT": "on",
"POST": "on"
}
}
So the installation works fine, I'm trying to update my module via zip upload, in this case Prestashop updates the module to the correct version, but does not set the permissions of the web service, perhaps because the install method is not executed during an upgrade?