I’m attempting to migrate from the hapikey to the private app key and this is the issue I’m encountering:
{"message":{"status":"error","message":"Authentication credentials not found. This API supports both API Key and OAuth 2.0 authentication and you can find more details at https://developers.hubspot.com/docs/methods/auth/oauth-overview","correlationId":"07a51d60-61f2-4489-acb5-68e238ddc67e","category":"INVALID_AUTHENTICATION"}}
Here is the general code I’m using which has worked when I use the hapikey key:
exports.main = ({body}, sendResponse) => {
const postAPI = "https://api.hubspot.com/cms/v3/hubdb/tables/{{ table }}/rows/{{ row }}/draft;
const widgetURL = "--------";
axios
.get(widgetURL)
.then(function (response) {
axios.
patch(postAPI, {
path: null,
name: null,
childTableId: 0,
values: {
"name": "widget",
"json": JSON.stringify(JSON.stringify(response.data))
},
headers: {
'Authorization': 'Bearer {{ Private App Key Here }}',
},
})
.then(function(response) {
console.log("HubDB table updated");
console.log(response.data);
console.log(response.status);
sendResponse({
statusCode: 200,
body: {
message: "HubDB table updated"
}
});
})
.catch(function(error) {
// Log failure response of the HubDB table create row API call
console.log("Failed to update HubDB table");
console.log(error.response.data);
console.log(error.response.status);
// Send failure response that the dontaion was received
sendResponse({
statusCode: 500,
body: {
message: error.response.data
}
});
})
.catch(function(error) {
console.log("Failed to get data");
console.log(error.response.data);
console.log(error.response.status);
// Send failure response that the dontaion was received
sendResponse({
statusCode: 500,
body: {
message: error.response.data
}
});
});
})
}
That’s because the widget api is calling a 3rd party api that requires no token. I realize that posting my entire code may have caused confusion. Here is a simplified version without the additional get call.