'visitorIdentification' property is undefined during user token generation

Hello there! This is my first time posting, so my apologies if I’m asking in the wrong place. I tried searching for an answer to this online, but I couldn’t find any information.

I’m currently testing user token generation via the code on the Visitor Identification page, specifically the Node example. I’ve added my oAuth token to the hubspotClient definition, and I imported '@hubspot/api-client` to my package.json before re-uploading my node modules. It all seems to be going well aside from one hiccup in the try block:

Property 'visitorIdentification' does not exist on type 'Client'.

Here are the lines where the error occurs; keep in mind that this is taken directly from the Node example on the page linked above:

try { const apiResponse = await hubspotClient.visitorIdentification.tokens.create.generateApi.generateToken( IdentificationTokenGenerationRequest, );console.log(JSON.stringify(apiResponse, null, 2));}

Edit: Just to be clear, I added my email, first name, and last name to IdentificationTokenGenerationRequest, so it should meet all required parameters. I just didn’t share that part because it’s personal information.

For context, here is my import statement:

import { Client } from '@hubspot/api-client';

Here is my definition for hubspotClient (I’ve stored my oAuth token in a variable on a previous line):

const hubspotClient = new Client({ accessToken: oAuthToken });

And here is the HubSpot import from my package.json:

"@hubspot/api-client": "^9.1.1"

I looked into the type definition of Client, and it doesn’t have a property labeled visitorIdentification. It does, however, have this property:

protected _conversations: ConversationsDiscovery | undefined;

…which led me to to this:

export default class ConversationsDiscovery extends BaseDiscovery { protected _visitorIdentification: VisitorIdentificationDiscovery | undefined; get visitorIdentification(): VisitorIdentificationDiscovery;};

So am I missing something in my code that allows a direct reference to visitorIdentification? I was able to generate a user token for my own email on the documentation page for Visitor Identification, but the code doesn’t work the same in my dev environment. If I’m completely off-base here, please let me know how else I can generate a token and I’ll happily redo my code! Thanks!

Hey, @JPHorner :waving_hand: Welcome to or community!

Did you get this resolved? If not, I’m happy to invite some of our community members to the conversation.

Best,

Jaycee

Hello Jaycee!

This hasn’t been resolved yet, but I’m in conversation with Andrea via email to get it sorted out. If she finds the solution to this problem, I’ll be sure to post it here for others as well! I appreciate the willingness to help.

Josh