I want to be able to authenticate using OAuth, then create a link from an external app back to a HubSpot page under the user login account selected during authentication. For example to let the user transition to working directly in the HubSpot UI.
What's the best way to get the base url so I can create links to contacts, deals, etc.?
I'm still new to the HubSpot API and I don't know all the terminology yet, so feel free to point me to docs with basic definitions like what a hub_id is. I'm specifically using the Nodejs api library.
I was able to dig through the Nodejs library code and find the getAccessToken() call. That returns among other data the hubId and userId in the AccessTokenInfoResponse object as in this crude code example:
console.log('=== Retrieving AccessTokenInfoResponse object for my token ===')
const result = await hubspotClient.oauth.defaultApi.getAccessToken(accessToken)
console.log('');
console.log(result.body)
That code displays a hubId consistent with the id in URL when I view pages in HubSpot for the linked account, confirming my guess above. So I can use the hubId to create links back to HubSpot contact and other pages.
Also note that this posted solution says the only way to get the user id "is through this endpoint: Get Information for OAuth 2.0 Access Token. " That was back in May 2020, so this library call may be new, but I was able to get the user id through the library call rather than https endpoint.
Also note it provides user, hubDomain, scopes, expiresIn, etc.
I was able to dig through the Nodejs library code and find the getAccessToken() call. That returns among other data the hubId and userId in the AccessTokenInfoResponse object as in this crude code example:
console.log('=== Retrieving AccessTokenInfoResponse object for my token ===')
const result = await hubspotClient.oauth.defaultApi.getAccessToken(accessToken)
console.log('');
console.log(result.body)
That code displays a hubId consistent with the id in URL when I view pages in HubSpot for the linked account, confirming my guess above. So I can use the hubId to create links back to HubSpot contact and other pages.
Also note that this posted solution says the only way to get the user id "is through this endpoint: Get Information for OAuth 2.0 Access Token. " That was back in May 2020, so this library call may be new, but I was able to get the user id through the library call rather than https endpoint.
Also note it provides user, hubDomain, scopes, expiresIn, etc.