# Visitor identification with auth flow

**URL:** <https://community.hubspot.com/t/visitor-identification-with-auth-flow/101396>\
**Category:** CMS Development\
**Tags:** javascript\
**Created:** [February 29, 2024, 12:56pm UTC](https://community.hubspot.com/t/visitor-identification-with-auth-flow/101396 "2024-02-29T12:56:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AGrek](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@AGrek](https://community.hubspot.com/u/AGrek)\
**Post date:** [February 29, 2024, 12:56pm UTC](https://community.hubspot.com/t/visitor-identification-with-auth-flow/101396/1 "2024-02-29T12:56:48Z")

</div>

I have a SPA application. To access the main content, authorization is required. I have connected the HubSpot LiveChat widget.

I want to implement the following:

- If the user is not authorized, the chat is available to them as an “Unknown Visitor.”  
- If the user is authorized, it is necessary to set the email and token for the chat. I found the following method:

```lia-code-sample
window.hsConversationsSettings = {
identificationEmail: "visitor-email@example.com",
identificationToken: "<TOKEN FROM STEP 1>"
};
window.HubSpotConversations.resetAndReloadWidget();

```

- If the user logs out, I need to remove their data from the chat. For this, I use the following code:

`window.HubSpotConversations.clear();`

Please advise on how to correctly implement this logic.
