To generate a token:
Gather the following information:
client_id. The client ID from the client credentials you created.client_secret. The client secret from the client credentials you created.grant_type. The type of grant. Use client_credentials.scope. The scope or permissions that you want the token to have. These are a subset of the entitlements that you used to generate the client ID and client secret.
Create base64-encoded client credentials using a base64 encoder of your choice. You can use one of various command line tools or this online tool. The input should be in the format of
client_id:client_secret.Make a POST request to the token generation endpoint (https://auth.trellix.com/auth/realms/IAM/protocol/openid-connect/token) with the required parameters in the request body. You can use various tools or programming languages to make the POST request. In the cURL example below, replace <BASE64_CLIENTCRED> with base64 encoded client credentials from step 2, and replace <SCOPE> with a space-separated list of scopes. For example,
scope=xdr.alr.r xdr.org.adm.curl --location 'https://auth.trellix.com/auth/realms/IAM/protocol/openid-connect/token' \ --header 'Authorization: Basic '<BASE64_CLIENTCRED>' \ --header 'content-type: application/x-www-form-urlencoded' \ --data-urlencode 'scope=<SCOPE> \ --data-urlencode ‘grant_type=client_credentials’Send the POST request and handle the response. The response is in JSON format and typically contains information such as the access token, token type, expiration time, and so on. You can extract the access token from the response to use it in your subsequent API requests. An example cURL response is below.
{"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJTMUVwVjQtaHpSMHhneGlhX2RDd0daS3NrT3h4Y3FERXdTMlJoejVfYlZvIn0.eyJleHAiOjE2OTExNDU1NTcsImlhdCI6MTY5MTE0NDk1NywianRpIjoiOTVjMmM5ZjAtMDY3MC00ZDBkLTk4NTItNTQ0MTJiYjVhYjM5IiwiaXNzIjoiaHR0cHM6Ly9hdXRoLnRyZWxsaXgd885I6InRyZWxsaXgiLCJzdWIiOiIxZjgyMDZkZi1lNjVjLTQxYmUtYmI0Yy1jOGYzMTIxOGZkN2MiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiI5ODNjZjlmOTQxYzBiYjFlMmEwMDAzZTMwNWVlMTZkMyIsImFjciI6IjEiLCJzY29wZSI6Inhkci5vcmcuYWRtIHhkci5hbHIuciIsInRlbmFudF9pZCI6Ijc2REMxQTcxLURBNzktNEQ5Mi1BQ0UwLUNDMkVERDVEOUVFQiIsImNsaWVudElkIjoiOTgzY2Y5Zjk0MWMwYmIxZTJhMDAwM2UzMDVlZTE2ZDMiLCJlbWFpbCI6ImRvbi5nb29kbWFuQHRyZWxsaXguY29tIn0.h5BhXPwTk7RgyCLHJQFgd5YixcXdhezhiXXlbmAYL9IKg47IQAo57BSh8EzXLZ1fCeBTsna1Wu8Sp42mmDoKrFhEYJ8Q5KQSNFYBoB6G-f_M9KKKpCRo-jp2nBkRiiWmd3zoiMau8yFV7oV2eTOicmA3VCyg0UdTSN27jkiu-PoZR6_67UL6LZ9ImQwfq2_Gyg3njlGQDihFlB3_IMU5Xxi3Q5PDsiBjzj7IePutivwmen0lP6NPj8ztIRjRgglDAAO2hAePGit9kr3-27b7exVbNC8TcbOfKK9ZwQUii9GsdW-WmFMKI6qPfFNs47y0QcQGPphV21VgSSyPadRRSw","expires_in":600,"refresh_expires_in":0,"token_type":"Bearer","not-before-policy":0,"scope":"xdr.org.adm xdr.alr.r"}%Note
Use proper security measures, such as securely storing the client secret and transmitting the requests over a secure connection, such as HTTPS.
Remember to adapt the code or tool to the programming language or environment you are using. This example uses cURL for illustration.