APIs & Integrations

Kevin-C
Experto reconocido | Partner
Experto reconocido | Partner

API Key to Private App Migration: Authentication credentials not found

Hey all!

 

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

 

 

 

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:

 

 

{
  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 any insights?

 

Best,

 

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
0 Me gusta
3 Respuestas 3
Kevin-C
Experto reconocido | Partner
Experto reconocido | Partner

API Key to Private App Migration: Authentication credentials not found

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 🙃.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
0 Me gusta
Jaycee_Lewis
Administrador de la comunidad
Administrador de la comunidad

API Key to Private App Migration: Authentication credentials not found

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

 

You are appreciated, @Kevin-C 🙌 — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Me gusta
himanshurauthan
Líder intelectual | Partner nivel Elite
Líder intelectual | Partner nivel Elite

API Key to Private App Migration: Authentication credentials not found

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.

Digital Marketing & Inbound Expert In Growth Hacking Technology