# API Key to Private App Migration: Authentication credentials not found

**URL:** <https://community.hubspot.com/t/api-key-to-private-app-migration-authentication-credentials-not-found/80283>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [April 28, 2023, 5:40pm UTC](https://community.hubspot.com/t/api-key-to-private-app-migration-authentication-credentials-not-found/80283 "2023-04-28T17:40:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin-C](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevin-c/32/34570_2.png) [@Kevin-C](https://community.hubspot.com/u/Kevin-C)\
**Post date:** [April 28, 2023, 5:40pm UTC](https://community.hubspot.com/t/api-key-to-private-app-migration-authentication-credentials-not-found/80283/1 "2023-04-28T17:40:36Z")

</div>

Hey all!

I’ve got this serverless, just migrated to private app auth:

```lia-code-sample
exports.main = async (context, sendResponse) => {
 const authToken = process.env.sparkling_zoo;
 const session_id = context.params.sid;
 const payload_archiveSession = {
 sn_archived: true,
 };
 const endpoint_archiveSession = `https://api.hubapi.com/crm/v3/objects/2-3994900/${session_id}/`;
 const headers = {
 "Content-Type": "application/json",
 Accept: "application/json",
 Authorization: `Bearer ${authToken}`
 };

 // Update playgroup
 try {
 const response_archiveSession = await patchObject(
 payload_archiveSession,
 headers,
 endpoint_archiveSession
 );

 sendResponse({
 body: {
 response: response_archiveSession.data,
 },
 statusCode: 200,
 });
 } catch (error) {
 console.log(error);
 sendResponse({
 body: {
 error: error,
 },
 statusCode: 500,
 });
 }
};

```

And I get the response:

```lia-code-sample
{
 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: '7070227d-f1a6-4dec-bf50-3ff52d7c4f29',
 category: 'INVALID_AUTHENTICATION'
}
2023-04-28T17:24:42.112Z INFO 401
2023-04-28T17:24:42.112Z INFO {
 date: 'Fri, 28 Apr 2023 17:24:42 GMT',
 'content-type': 'application/json;charset=utf-8',
 'content-length': '316',
 connection: 'close',
 'cf-ray': '7bf100123d5c5943-IAD',
 'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
 vary: 'origin',
 'cf-cache-status': 'DYNAMIC',
 'access-control-allow-credentials': 'false',
 'x-hubspot-auth-failure': '401 Unauthorized',
 'x-hubspot-correlation-id': '7070227d-f1a6-4dec-bf50-3ff52d7c4f29',
 'x-trace': '2BCADEFF9EAC1EC6F060FF087DC2950FEAC4CDA6B8000000000000000000',
 'report-to': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=QtvlmIGqU1BIUSnIGzG39klIxjRCkVC%2BvAKtoVTiF32d6vOMM242CXacvlGzhRoBUGoELHX%2FMx7tSupXFMgyKd66Bp7krZbtr56F1jkKxtGtvTb%2BBa891CE1cYLL7RZc"}],"group":"cf-nel","max_age":604800}',
 nel: '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}',
 server: 'cloudflare',
 'alt-svc': 'h3=":443"; ma=86400, h3-29=":443"; ma=86400'
}

```

This is happening for all function is the portal 😞

I’ve triple checked that the private app has the correct scope(it now has all of them), that the private app is accessible in the function(console logged it out), and still coming up with nothing.

We get no logs in the Private App HS view. The logs shown are from the terminal.

If I revert this back to api keys with no other changes the functino works as expected.

[@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074) any insights?

Best,

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [May 1, 2023, 8:13am UTC](https://community.hubspot.com/t/api-key-to-private-app-migration-authentication-credentials-not-found/80283/2 "2023-05-01T08:13:11Z")

</div>

Hello @Kevin-C  
Based on the error message you provided, it seems that the authentication credentials are not being passed correctly to HubSpot’s API.

---

<div class="post-metadata">

**Author:** ![Kevin-C](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevin-c/32/34570_2.png) [@Kevin-C](https://community.hubspot.com/u/Kevin-C)\
**Post date:** [May 1, 2023, 2:52pm UTC](https://community.hubspot.com/t/api-key-to-private-app-migration-authentication-credentials-not-found/80283/3 "2023-05-01T14:52:51Z")

</div>

Following up on this.  
After working extensively with support and our CAM it was discovered that there is a bug on the HS side preventing the auth from being accepted by the endpoint 🙃.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [May 1, 2023, 4:25pm UTC](https://community.hubspot.com/t/api-key-to-private-app-migration-authentication-credentials-not-found/80283/4 "2023-05-01T16:25:19Z")

</div>

Thanks for taking the time to flag this and follow up about it. I was OOO on Friday.

You are appreciated, @Kevin-C 🙌 — Jaycee
