Get user token
This method is only available for JavaScript.
Required API Key:
any key with the
search
ACL
Only available for JavaScript
You’re currently reading the Ruby API client v2 documentation. Check the migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.
About this method
Get the anonymous user token from the Insights API Client state.
Use this method to keep track of the anonymous user token generated by the Insights API Client.
Examples
Read the Algolia CLI documentation for more information.
The following example initializes the Insights API client aa
with a generated anonymous user token.
1
2
3
4
5
6
import aa from "search-insights";
aa('init', {
appId: 'YourApplicationID',
apiKey: 'YourSearchOnlyAPIKey',
});
Then, retrieve the generated user token.
1
2
3
4
5
6
7
8
aa('getUserToken', {}, (err, userToken) => {
if (err) {
console.error(err);
return;
}
console.log(userToken);
});
Parameters
options
|
type: object
The options to retrieve the user token. This argument isn’t used for now, so you can pass an empty object. |
callback
|
type: (err: Error, userToken: string) => void
The function called with a possible error and the user token. |
Response
This method doesn't return a response.