I’m trying to use the new Journal polling mechanism and need to set up the Journal API (create subscriptions, ecc.)
Can my app (Distribution: Private, Auth Type: OAuth) request a client_credentials token at the endpoint: https://api.hubapi.com/oauth/v1/token using the following scopes?
developer.webhooks_journal.read
developer.webhooks_journal.subscriptions.read
developer.webhooks_journal.subscriptions.write
developer.webhooks_journal.snapshots.read
developer.webhooks_journal.snapshots.write
The app is correctly installed on the Hubspot account.
When I attempt to request the token to set up the Journal, I receive the following error:
HTTP Error: 400 Bad Request
{"status":"BAD_GRANT_TYPE","message":"missing or unknown grant type","correlationId":"1fd8fddc-cb6b-447e-845a-5aa9a741dc98"}
I’m following the documentation here:
- https://developers.hubspot.com/docs/apps/developer-platform/build-apps/overview#features(shows that Webhooks v4 is an enabled feature for OAuth Private Apps)
- https://developers.hubspot.com/docs/apps/developer-platform/build-apps/authentication/overview#client-credentials (shows the example API call I’m following exactly)
- https://developers.hubspot.com/docs/api-reference/webhooks-webhooks-v4/webhooks-journal#authentication
Here’s my Python code in case something obvious is missing:
import urllib.request
import urllib.parse
scopes = [
"developer.webhooks_journal.read",
"developer.webhooks_journal.subscriptions.read",
"developer.webhooks_journal.subscriptions.write",
"developer.webhooks_journal.snapshots.read",
"developer.webhooks_journal.snapshots.write",
]
data = {
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": client_secret,
"scope": " ".join(scopes),
}
encoded_data = urllib.parse.urlencode(data, quote_via=urllib.parse.quote).encode("utf-8")
url = "https://api.hubapi.com/oauth/v1/token"
headers = {"Content-Type": "application/x-www-form-urlencoded"}
req = urllib.request.Request(
url, data=encoded_data, headers=headers, method="POST"
)
try:
with urllib.request.urlopen(req) as response:
response_data = response.read().decode("utf-8")
print("Response:")
print(response_data)
except urllib.error.HTTPError as e:
print("HTTP Error:", e.code, e.reason)
print(e.read().decode())
except urllib.error.URLError as e:
print("URL Error:", e.reason)