We are trying to build an integration between our application and HubSpot that will trigger creation of data in our application based on an event in Hubspot (e.g. contact creation). I understand the OAuth flow required to make our integration available to HubSpot portals, but there is something I'm missing.
When a webhook payload is sent, it will identify the id of the object triggering the event as well as the portal id (which I understand correlates with the organization using HubSpot). In order to get the data for the newly created object, we need to use the API, which requires that we provide the access token given to our app when the user granted access.
What I'm missing is how do I correlate the access token issued with the portal id? I have not seen that a portal id is sent when the users are initially directed to our app. I could add that as a query parameter on the redirect url, but now I need a different url and hence app for every portal. Is a different app for every portal the recommended way to integrate with multiple HubSpot portals? Also I've read on these forums I can't put query parameters in the redirect url. If that is true, then I would need to put the parameter on the app url, but then does the HubSpot Oauth support the state parameter (not specified in the documentation) so that I can pass information back to my redirect url from the initial authorize request?