--- title: Generate a custom search token for the Community Hosted Search Page component slug: obkd0147 canonical_url: https://docs.coveo.com/en/obkd0147/ collection: coveo-for-salesforce source_format: adoc --- # Generate a custom search token for the Community Hosted Search Page component > **Available since** > > This feature was introduced in the January 2025 release of Coveo for Salesforce version [6.2](https://docs.coveo.com/en/ob460496#january-2025-release-v6-2-minor-release). To override the default [search token](https://docs.coveo.com/en/1346/) for your Community Hosted Search Page configuration, you must generate a custom search token to [authenticate](https://docs.coveo.com/en/2120/) queries on the **Coveo Community Hosted Search Page** component. Custom search tokens are typically used to add additional parameters to the search token. See [Use search token authentication](https://docs.coveo.com/en/56/) for details. To generate a custom search token . [Create an Apex class](https://help.salesforce.com/s/articleView?id=platform.code_manage_packages.htm&type=5). . In the new Apex class, enter the following template: ```apex global with sharing class implements CoveoV2.SearchTokenGeneratorInterface { public String generateSearchToken(Map params) { Map searchTokenOptions = new Map(); // Make sure to include this part when generating your custom search token. if (params.containsKey('searchHub')) { String searchHub = (String) params.get('searchHub'); searchTokenOptions.put('searchHub', searchHub); } // Example of how to add additional user identities to the search token. List additionalUserIdentities = new List{ new CoveoV2.UserIdentity('johndoe@coveo.com'), new CoveoV2.UserIdentity('john@doe.com', 'Email Security Provider'), new CoveoV2.UserIdentity('john@doe.com', 'Email Security Provider', 'User') }; searchTokenOptions.put('additionalUserIdentities', additionalUserIdentities); String token = CoveoV2.Globals.generateSearchToken(searchTokenOptions); return token; } } ``` Where you replace `` with the name you chose for your new Apex class. > **Important** > > The Apex class must be `global` and it must implement `CoveoV2.SearchTokenGeneratorInterface`. > Otherwise, it won't appear as an option in the [**Token Generator**](https://docs.coveo.com/en/o3lb0328#search-token-generator) picklist on the **Coveo Community Hosted Search Page** component. . (Optional) Override the default search token parameters. See the [`generateSearchToken`](https://docs.coveo.com/en/1075#generatesearchtoken) reference documentation for details. > **Warning** > > The value of the `searchHub` parameter received when the `generateSearchToken` function is called will match the name of your hosted search page configuration. > This value must not be changed and it must be added to the search token options. . Save the Apex class. ## What's next? Once you have an Apex class that implements `CoveoV2.SearchTokenGeneratorInterface`, it will appear as an option in the **Token Generator** picklist on the **Coveo Community Hosted Search Page** component. You can now [select your new Apex class](https://docs.coveo.com/en/o3lb0328#search-token-generator) to override the default search token for your Community Hosted Search Page configuration.