Webhooks API authentication using Oauth2.0


#1

I have a trial account where created an APP. I am able to create Webhook Subscription using hapikey but when using Outh token its showing the below error json response.

{
“status”: “error”,
“message”: “This oauth-token (token) does not have proper permissions! (cannot access an unscoped endpoint)”,
“correlationId”: “99bb5e04-eac4-4e04-a5f1-a5a7060b78bb”,
“requestId”: “b8d2a4f4-6086-45a0-8935-d4210be5afa7”
}
FYI : My Scopes to the App are : contacts,automation,content …

Which scope I am missing here.


#2

@Shreekanta_Panigrahi Which endpoint are you trying to hit?


#3

@pmanca

I am hitting

https://api.hubapi.com/webhooks/v1//subscriptions

with post parameters to manage subscriptions.


#4

@Shreekanta_Panigrahi are you including the appId in your call?


#5

Yes @pmanca
I am adding my app_id in the call.


#6

@Shreekanta_Panigrahi I did some research back here. The correct way to authenticate in to create a subscription is to use your developer hapikey. You only need oauth to install the app that the webhook subscription is on.

Here is an example.

https://api.hubapi.com/webhooks/v1/<<app ID>>/subscriptions?hapikey=xxxxx

with a post body set to application/JSON

{
“subscriptionDetails” : {
“subscriptionType” : “company.propertyChange”,
“propertyName” : “companyname”
},
“enabled” : false
}


#7

@pmanca

It will work with hapikey but I found below message in Authentication overview :

➜ ~ curl https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=demo
(Deprecated, but included for completness) Using OAuth v1, which uses the access_token= query parameter in the URL .

Thats why I want to do it using OAuth2.0 .

Please suggest…


#8

@Shreekanta_Panigrahi Since the dev apps are independent of any portal you will need to use your developer hapikey. The Oauth tokens are to log into one normal hubspot portal.