Access Keys with SDKs
If you wish to learn more about Access Keys in general, visit our section on Access Key Management.
You can use Descope Management SDK for common access key management operations like create access key, update custom claims, delete access key, etc.
Install SDK
The Management SDK requires a management key, which can be generated here.
Import and initialize Management SDK
Create Access Key
This operation is used to create an access key. At the time of creation of the access key, you can provide the name, expiration duration, tenants, and roles associated with the key. After the successful creation of the key, the response object contains id of the key and key value. The key value is only delivered at the creation time from Descope service, and your application must store or deliver to the connecting machine based on your use case. Your application can use the key id for updating the name, deleting, etc. An access key must have a name and expiration, other fields are optional. Roles should be set directly if no tenants exist, otherwise set on a per-tenant basis.
Load Access Key
The Descope SDK allows administrators to use a management key to load details of an existing access key.
Search Access Keys
The Descope SDK allows administrators to use a management key to search for existing access keys. Administrators can search all or search based on a specific tenantIds.
Update Access Key
The Descope SDK allows administrators to use a management key to update the name of an existing access key. It is important to note that all parameters are used as overrides to the existing access key; empty fields will override populated fields.
Activate Access Key
The Descope SDK allows administrators to use a management key to activate an existing access key that is currently deactivated.
Deactivate Access Key
The Descope SDK allows administrators to use a management key to deactivate an existing access key. After deactivating an access key, it will no longer be usable. The key will persist within the project, and can be activated again if needed.
Delete Access Key
The Descope SDK allows administrators to use a management key to delete an existing access key. Once an access key is deleted, it is removed from the project and no longer usable. This action is irreversible.
Exchange Access Keys
The Descope SDK allows for exchanging access keys for a JWT token. For machine-to-machine
communication, the machine connecting to your application presents an access key, and a JWT
token is returned to the connecting machine. The connecting machine can then use this JWT
token to make API calls to your application.
You can also provide this method with a custom claims object, that will eventually nest the custom claims
inside the nsec
key. The custom claims that sit under nsec
are in a less secure state by definition in contrast to custom claims
that are created with the access key itself.