token_lifetime_policies
Creates, updates, deletes, gets or lists a token_lifetime_policies resource.
Overview
| Name | token_lifetime_policies |
| Type | Resource |
| Id | entra_id.service_principals.token_lifetime_policies |
Fields
The following fields are returned by SELECT queries:
- list
Retrieved collection
| Name | Datatype | Description |
|---|---|---|
id | string | The unique identifier for an entity. Read-only. |
appliesTo | array | |
definition | array | A string collection containing a JSON string that defines the rules and settings for a policy. The syntax for the definition differs for each derived policy type. Required. |
deletedDateTime | string (date-time) | Date and time when this object was deleted. Always null when the object hasn't been deleted. (pattern: ^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$) |
description | string | Description for this policy. Required. |
displayName | string | Display name for this policy. Required. |
isOrganizationDefault | boolean | If set to true, activates this policy. There can be many policies for the same policy type, but only one can be activated as the organization default. Optional, default value is false. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list | select | service_principal_id | List the tokenLifetimePolicy objects that are assigned to a servicePrincipal. Only one object is returned in the collection because only one tokenLifetimePolicy can be assigned to a service principal. | |
add_ref | insert | service_principal_id | Assign a tokenLifetimePolicy to a servicePrincipal. You can have multiple tokenLifetimePolicy policies in a tenant but can assign only one tokenLifetimePolicy per service principal. | |
remove_ref | delete | service_principal_id, token_lifetime_policy_id | If-Match | Remove a tokenLifetimePolicy object from a service principal. |
remove_ref_2 | delete | service_principal_id | If-Match | Remove a tokenLifetimePolicy object from a service principal. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
service_principal_id | string | The unique identifier of servicePrincipal |
token_lifetime_policy_id | string | The unique identifier of tokenLifetimePolicy |
If-Match | string | ETag |
SELECT examples
- list
List the tokenLifetimePolicy objects that are assigned to a servicePrincipal. Only one object is returned in the collection because only one tokenLifetimePolicy can be assigned to a service principal.
SELECT
id,
appliesTo,
definition,
deletedDateTime,
description,
displayName,
isOrganizationDefault
FROM entra_id.service_principals.token_lifetime_policies
WHERE service_principal_id = '{{ service_principal_id }}' -- required
;
INSERT examples
- add_ref
- Manifest
Assign a tokenLifetimePolicy to a servicePrincipal. You can have multiple tokenLifetimePolicy policies in a tenant but can assign only one tokenLifetimePolicy per service principal.
INSERT INTO entra_id.service_principals.token_lifetime_policies (
directoryObjectId,
service_principal_id
)
SELECT
'{{ directoryObjectId }}',
'{{ service_principal_id }}'
;
# Description fields are for documentation purposes
- name: token_lifetime_policies
props:
- name: service_principal_id
value: "{{ service_principal_id }}"
description: Required parameter for the token_lifetime_policies resource.
- name: directoryObjectId
value: "{{ directoryObjectId }}"
description: |
The id of the directory object to reference (a user, group, service principal, device, ...). Sent on the wire as '@odata.id': 'https://graph.microsoft.com/v1.0/directoryObjects/{id}'.
DELETE examples
- remove_ref
- remove_ref_2
Remove a tokenLifetimePolicy object from a service principal.
DELETE FROM entra_id.service_principals.token_lifetime_policies
WHERE service_principal_id = '{{ service_principal_id }}' --required
AND token_lifetime_policy_id = '{{ token_lifetime_policy_id }}' --required
AND If-Match = '{{ If-Match }}'
;
Remove a tokenLifetimePolicy object from a service principal.
DELETE FROM entra_id.service_principals.token_lifetime_policies
AND service_principal_id = '{{ service_principal_id }}' --required
AND If-Match = '{{ If-Match }}'
;