APIs & Integrations

DVernon
Member

Webhooks for getting deleted deals

SOLVE

Hi,

 

I am trying to get notified when a deal is deleted so have set up an app and installed it at last. I have slowly got to the stage where I need to access and refresh tokens to get my new app to appear in Hubspot (and then hopefully my webhook will work). But it looks like I need to run this code:

POST URL:
https://api.hubapi.com/oauth/v1/token
Headers:
Content-Type: application/x-www-form-urlencoded;charset=utf-8
Data:
grant_type=authorization_code&client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&client_secret=yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy&redirect_uri=https://www.example.com/&code=zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz



 Does anyone know how / what tool to run this code in? Is it Node.Js as I don't know that. 

 

Any help much appreciated.

0 Upvotes
1 Accepted solution
zaklein
Solution
Contributor | Platinum Partner
Contributor | Platinum Partner

Webhooks for getting deleted deals

SOLVE

Hi @DVernon 

There are a number of guides to working with OAuth offered by HubSpot.

I recommend following along with the example outlined in the "OAuth Quickstart Guide".

It sounds like you might be up to "Step 4: Exchange authorization code for tokens" with your app, but I'd recommend going through the entire guide from start to finish, to make sure you understand the ins and outs of OAuth for HubSpot.

Addressing your question directly, the API function you are describing is exchanging an authorization code (appended as a query parameter by HubSpot to your app's installation redirect URL) for an access token and a refresh token (POST /oauth/v1/token, where documentation can be found under "Tokens" heading within "Endpoints" tab on this page).

The actual mechanism that makes this call is completely up to you, and likely will depend on the tech stack you are using to build your app (might be Node.js, or maybe Python's Flask -- HubSpot's API documentation has examples in languages/frameworks such as cURL, Node.js, PHP, Ruby, Python, C#). It is possible (though not recommended outside of initial testing) to simply make these OAuth API calls yourself manually using an API testing tool like Postman.

I hope that proves helpful. I know OAuth can a tricky nut to crack the first time around. Stick with it 🙂

Let me know if you have any follow up questions.

Thanks and all the best,

Zach

View solution in original post

2 Replies 2
zaklein
Solution
Contributor | Platinum Partner
Contributor | Platinum Partner

Webhooks for getting deleted deals

SOLVE

Hi @DVernon 

There are a number of guides to working with OAuth offered by HubSpot.

I recommend following along with the example outlined in the "OAuth Quickstart Guide".

It sounds like you might be up to "Step 4: Exchange authorization code for tokens" with your app, but I'd recommend going through the entire guide from start to finish, to make sure you understand the ins and outs of OAuth for HubSpot.

Addressing your question directly, the API function you are describing is exchanging an authorization code (appended as a query parameter by HubSpot to your app's installation redirect URL) for an access token and a refresh token (POST /oauth/v1/token, where documentation can be found under "Tokens" heading within "Endpoints" tab on this page).

The actual mechanism that makes this call is completely up to you, and likely will depend on the tech stack you are using to build your app (might be Node.js, or maybe Python's Flask -- HubSpot's API documentation has examples in languages/frameworks such as cURL, Node.js, PHP, Ruby, Python, C#). It is possible (though not recommended outside of initial testing) to simply make these OAuth API calls yourself manually using an API testing tool like Postman.

I hope that proves helpful. I know OAuth can a tricky nut to crack the first time around. Stick with it 🙂

Let me know if you have any follow up questions.

Thanks and all the best,

Zach

dennisedson
Community Manager
Community Manager

Webhooks for getting deleted deals

SOLVE

@zaklein 

Maybe you have  working example to share on your OAuth setup?

On a side note, I did a quick search for a HubSpot specific example on this and didn't find one 😥

Might be time to create a tutorial.  What do you say @zaklein !

Thanks,

Dennis




HubSpot Community Developer ShowMake sure to subscribe to our YouTube channel
where you can find the HubSpot Community Developer Show
0 Upvotes