--- title: Use Case Assist with secured content slug: na6a5281 canonical_url: https://docs.coveo.com/en/na6a5281/ collection: service source_format: adoc --- # Use Case Assist with secured content Coveo Case Assist was designed to use [API key authentication](https://docs.coveo.com/en/1369#api-key-authentication), which means that only the content visible to an anonymous [user](https://docs.coveo.com/en/250/), such as public [sources](https://docs.coveo.com/en/246/) or [items](https://docs.coveo.com/en/210/), is returned. However, there are times you may need to display secured content, for example, perhaps your Case Assist implementation is dedicated to internal agents who must access secured items. For situations where secured content must be accessible through the Case Assist [**Document Suggestion**](https://docs.coveo.com/en/m1kf5061#document-suggestion) functionality, you'll need to use a [platform token](https://docs.coveo.com/en/n3ha0170/) instead of an API key to authenticate requests. This token, just like a [search token](https://docs.coveo.com/en/1346/), will contain the identity of the current user. ## Prerequisites - Complete all the steps outlined in the [Coveo Case Assist cookbook](https://github.com/coveooss/sf-case-assist-cookbook). - Ensure you have a working Case Assist deployment. ## Configure Case Assist to use a platform token The code deployed by the [Coveo Case Assist cookbook](https://github.com/coveooss/sf-case-assist-cookbook) includes two important components: the `CaseAssistInterface` Lightning Web Component (LWC) and the `CaseAssistController` Apex class. ### `CaseAssistInterface` Lightning Web Component `CaseAssistInterface` is an extension of the [`QuanticCaseAssistInterface`](https://docs.coveo.com/en/quantic/latest/reference/case-assist-components/case-assist-case-assist-interface/) component. It changes the Apex class that's called to use the `CaseAssistController` in order to generate the token that will be used to authenticate the Case Assist API calls. ### `CaseAssistController` Apex class `CaseAssistController` is the class that must be modified to use a [platform token](https://docs.coveo.com/en/n3ha0170/) instead of the default API key. This class provides the following sample method, which is a reference on how to use an API key for Case Assist. ```apex @AuraEnabled public static String getHeadlessConfiguration() { Map headlessConfiguration = new Map(); headlessConfiguration.put('organizationId', 'searchuisamples'); headlessConfiguration.put( 'accessToken', '' ); return JSON.serialize(headlessConfiguration); } ``` Following this sample method, you'll see another method which shows you how to use a [platform token](https://docs.coveo.com/en/n3ha0170/) instead. > **Important** > > The following method will be commented out by default. ```apex @AuraEnabled public static String getHeadlessConfiguration() { Map platformTokenParams = new Map(); // The platform token needs to request the required privileges to use Case Assist. <1> List privileges = new List(); // Adding the required privilege to use Case Assist. privileges.add( new CoveoV2.PlatformToken.TokenPrivilege( 'CUSTOMER_SERVICE', 'USE_CASE_ASSIST', 'ENABLE' ) ); // Adding the required privilege to log analytics. privileges.add( new CoveoV2.PlatformToken.TokenPrivilege( 'USAGE_ANALYTICS', 'ANALYTICS_DATA', 'EDIT' ) ); platformTokenParams.put('privileges', privileges); // Generate the platform token by calling the Coveo platform. <2> String platformToken = CoveoV2.Globals.generatePlatformToken( platformTokenParams ); // Add additional required information to create the Case Assist endpoint. <3> Map headlessEndpointData = CoveoV2.Globals.getEndpointData(); Map headlessConfiguration = new Map(); headlessConfiguration.put('accessToken', platformToken); headlessConfiguration.put( 'organizationId', (String) headlessEndpointData.get('organization') ); return JSON.serialize(headlessConfiguration); } ``` <1> Requests the appropriate privileges to be able to use the Case Assist APIs through token privileges. <2> Generates a {platform-token} using `CoveoV2.Globals.generatePlatformToken`, a method that's part of the Coveo for Salesforce package. This method generates the token with the current user's identity, as well as the {privileges} requested in step 1. <3> Adds additional data to the returned {headless} configuration such as the Coveo `organizationId`, as well as the `platformUrl`. This data is required by the {quantic} framework to function properly. > **Important** > > To use the [quickview](https://docs.coveo.com/en/3311/) functionality with **Document Suggestions**, add the `EXECUTE_QUERY` [privilege](https://docs.coveo.com/en/228/) to the list of [privileges](https://docs.coveo.com/en/228/) as follows: > > ```apex // Adding the required privileges to use the quickview functionality with Document Suggestions. privileges.add( new CoveoV2.PlatformToken.TokenPrivilege( 'SEARCH_API', 'EXECUTE_QUERY', 'ENABLE' ) ); ``` To configure Case Assist to use a [platform token](https://docs.coveo.com/en/n3ha0170/) . Access the `CaseAssistController` Apex class, and then perform the following steps: .. Comment out the sample method that uses an API key. .. Uncomment the method that uses a [platform token](https://docs.coveo.com/en/n3ha0170/). .. (Optional) To use the [quickview](https://docs.coveo.com/en/3311/) functionality with **Document Suggestions**, add the `EXECUTE_QUERY` [privilege](https://docs.coveo.com/en/228/) to the list of [privileges](https://docs.coveo.com/en/228/) required by the [platform token](https://docs.coveo.com/en/n3ha0170/). . Save the Apex class. Your Case Assist interface is now configured to use a [platform token](https://docs.coveo.com/en/n3ha0170/) instead of an API key.