APIs & Integrations

vivek_kadam
Member

Unable to identify user by webhook response

I have created an app for getting web-hook whenever a contacted is added. Also I have implemented OAuth2 for getting the contact details. But this app can be used by multiple users and I didn't find any unique token in OAuth2 process which I can save to Identify the user. How can I Identify the user from webhook content.

Getting webhook response :
[{"objectId":651,"changeFlag":"NEW","changeSource":"CONTACTS","eventId":500481316,"subscriptionId":11741,"portalId":4337833,"appId":61614,"occurredAt":1519647380679,"subscriptionType":"contact.creation","attemptNumber":0}]

0 Upvotes
3 Replies 3
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Unable to identify user by webhook response

Hi @vivek_kadam,

If you have 10 users go through your OAuth flow, you'll get 10 access tokens. These tokens aren't specific to a particular HubSpot user; they're specific to a particular HubSpot portal. Webhook notifications include the portal ID, allowing you to identify which notifications are related to which portal. You should store the access token / portal relationship internally; the following endpoint can provide this info as well:

0 Upvotes
vivek_kadam
Member

Unable to identify user by webhook response

Hi @Derek_Gervais,

Thanks for the reply, but I think you are not getting it. Let me take an example for better explanation.
Suppose I have 10 users which are using my Hubspot app. All OAuth process has been done and I got a webhook notification and I have 10 Access token saved for 10 user. How can I identify that the webhook belongs to user1 or user2 because I didn't find any field that identify the web-hook belongs to which user and so that I can retrieve details using the right access token.

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Unable to identify user by webhook response

Hi @vivek_kadam,

Currently, the changeSource field will show the source of the change that resulted in the webhook notification according to the following Knowledge Base article. It won't always reflect a particular user, since not all updates are done by users. When a change (like a property change) is made by a user, the user's email address should show up under changeSource.

0 Upvotes