Newer Version Available
TenantSecret
You can rotate the tenant secret once every four hours in a sandbox organization or every 24 hours in production organizations.
Fields
| Field Name | Details |
|---|---|
| Description |
|
| SecretValue |
|
| Status |
|
| Version |
|
Usage
Use this object to create or update your organization-specific tenant secret. For example, you can build an automated tenant secret creation and activation solution similar to the following.
- Start by creating an Apex class to create
the new tenant secret.
1global class CreateNewSecret implements Schedulable { 2 global void execute(SchedulableContext SC) { 3 TenantSecret k = new TenantSecret (); 4 k.description = 'Created new secret from scheduled job'; 5 insert k; 6 } 7} - Schedule the Apex
class to run at the specified interval.
This Apex code only needs to be run a single time to schedule the job. This code runs the job every 90 days.
1CreateNewSecret secret = new CreateNewSecret(); 2String schedule = '0 0 0 1 JAN,APR,JUL,OCT ?'; 3String jobID = system.schedule('Automated secret creation and activation', schedule, secret); - Validate that the job is scheduled.
- Validate that tenant secrets are created after the job is run.
Here is an example of destroying a tenant secret.
1TenantSecret secret = [SELECT Id FROM TenantSecret WHERE Version = 2];
2secret.SecretValue = NULL;
3update secret;