AssetTokenEvent

Represents an event associated with an asset token, such as token issuance and registration of a connected device as an Asset. This object is available in API version 39.0 and later.

An asset token event records successful completion of an OAuth 2.0 asset token flow for a connected device. An event is published whenever an access token and actor token (optional) are successfully exchanged for an asset token. This object is designed to support custom business processes, such as automatic logging of a case when an event occurs. Create Apex triggers that subscribe to an event and execute after asset token issuance. This object is read only and can’t be retrieved using a SOQL query. Asset token events are not displayed in the Setup user interface for Platform Events.

Supported Calls

describeSObjects()

Fields

Field Name Details
ActorTokenPayload
Type
textarea
Properties
Nillable
Description
If the asset token request included an actor token, the payload portion containing claims about the connected device, asset token, and if applicable, the registered Asset.
AssetId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
ID of the Asset record if the Asset was newly created or an existing Asset was linked to in the asset token request.
AssetName
Type
string
Properties
Filter, Group, Nillable, Sort
Description
If specified in the actor token, the display name of the existing Asset. This value is otherwise null.
AssetSerialNumber
Type
string
Properties
Filter, Group, Nillable, Sort
Description
If specified in the actor token, the serial number of the existing Asset. This value is otherwise null.
ConnectedAppId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
ID of the connected app associated with the access token for the device.
DeviceId
Type
string
Properties
Filter, Group, Nillable, Sort
Description
ID of the connected device. Value is the did (device ID) claim specified in the actor token.
DeviceKey
Type
textarea
Properties
Nillable
Description
If specified in the actor token, the device-specific RSA public key as a JSON Web Key (JWK). Value is the jwk claim within the confirmation claim from the actor token.
Expiration
Type
dateTime
Properties
Filter, Nillable, Sort
Description
The expiration time on or after which the asset token JWT must not be accepted for processing. A numeric value representing the number of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time, ignoring leap seconds.
Name
Type
string
Properties
Filter, Group, Nillable, Sort
Description
Display name of the asset token.
ReplayId
Type
string
Properties
Filter, Nillable, Sort
Description
Numeric ID that identifies the asset token event. Each ID is incremented automatically and guaranteed to be higher than the ID of the previous event, but not necessarily contiguous for consecutive events.
UserId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
ID of the user associated with the access token.

Usage

The following example shows how to trigger an action after an asset token event.

trigger AssetTokenEventTrigger on AssetTokenEvent (after insert) {
      System.assertEquals(1,Trigger.new.size(),'One record expected');
      AssetTokenEvent event = Trigger.new[0];
      AssetTokenRecord__c record = new AssetTokenRecord__c();
      record.ConnectedAppId__c = event.ConnectedAppId;
      record.UserId__c = event.UserId;
      record.AssetId__c = event.AssetId;
      record.AssetTokenName__c = event.AssetTokenName;
      record.DeviceId__c = event.DeviceId;
      record.DeviceKey__c = event.DeviceKey;
      record.Expiration__c = event.Expiration;
      record.AssetSerialNumber__c = event.AssetSerialNumber;
      record.AssetName__c = event.AssetName;
      record.ActorTokenPayload__c = event.ActorTokenPayload;
      insert(record);
}