I have an issue, I created a CMT to store a token for a integration with thirdparty system, with the SA user works fine, but it doesn't work for other users, when I check the debug logs I saw this error: "System.NoAccessException: Not allowed to install or modify metadata via Apex"
This is the code to update the CMT:
Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();
customMetadata.fullName = 'PDB_Token.Token';
customMetadata.label = 'Token';
Metadata.CustomMetadataValue customFieldDate = new Metadata.CustomMetadataValue();
customFieldDate.field = 'Fecha_Token__c';
system.debug('#####token:');
system.debug(t);
customFieldDate.value = System.now().addSeconds(Integer.valueOf(t.expires_in));
customMetadata.values.add(customFieldDate);
Metadata.CustomMetadataValue customFieldToken = new Metadata.CustomMetadataValue();
customFieldToken.field = 'Token__c';
customFieldToken.value = t.access_token;
customMetadata.values.add(customFieldToken);
Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();
mdContainer.addMetadata(customMetadata);
CustomMetadataCallback callback = new CustomMetadataCallback();
Id jobId = Metadata.Operations.enqueueDeployment(mdContainer, callback);
I already gave these permissions: "Modify Metadata Through Metadata API Functions" and also I enabled the CMT that store the token.
So any of you knows what other permission I need to assign to the users so they can update the CMT via Apex?