APIs & Integrations

MJProvencher
Participant

Migrating from API Key to Private App with VIDs

SOLVE

In our existing API Key setup, we have these URLs to determine if we need to do an ADD or an UPDATE based on a match on the vid:
https://api.hubapi.com/contacts/v1/contact/vid/XXXX/profile?hapikey=XXXX;

How would I accomplish the same in the Private App setup, which references v3?
https://api.hubapi.com/crm/v3/objects/contacts

Thank you!

2 Accepted solutions
MJProvencher
Solution
Participant

Migrating from API Key to Private App with VIDs

SOLVE

Thanks for the reply—I think for developers more experienced, your response likely was a helpful solution.

Let me try to simplify my noob question:

Since I'm adding the access_token to the header with `Authorization: Bearer`, can I simply remove the hapikey param from these existing links, turning this:

 

$url = 'https://api.hubapi.com/contacts/v1/contact?hapikey=' . $api_key;

 

  into

 

$url = 'https://api.hubapi.com/contacts/v1/contact';

 

(in essence, leaving the rest of the implementation in place, since after passing the access_token in the headers, that handles the authentication?)

Again, sorry if these are super basic questions!

View solution in original post

0 Upvotes
ChehakWadhdwa
Solution
Member | Diamond Partner
Member | Diamond Partner

Migrating from API Key to Private App with VIDs

SOLVE

Hey  @MJProvencher

 

Yes, you can remove hapikey param from these existing links as these will be of no use from 1 December 2022 according to new privacy & policy changes of hubspot. All endpoints will rely on Private Apps that are the Authorization Bearer tokens.



Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

View solution in original post

4 Replies 4
ChehakWadhdwa
Member | Diamond Partner
Member | Diamond Partner

Migrating from API Key to Private App with VIDs

SOLVE

Hey @MJProvencher

 

Hey there it feels like you still need rely on V1 

Still you can have a look at the below link - >

https://community.hubspot.com/t5/APIs-Integrations/API-for-contacts-v1-contact-vid-vid-profile-in-V3...

 

Regarding the migration ->

  • Go to you settings console on your hubspot account
    • Create a new private app for contacts
      • Define the scope 

         

        Check the contact scopes from here ->

        https://developers.hubspot.com/docs/api/crm/contacts

         

        Check the below image ->

         

         

        ChehakWadhdwa_0-1665651927074.png

        Hope this helps!

        If we were able to answer your query, kindly help the community by marking it as a solution.

        Thanks and Regards.

MJProvencher
Solution
Participant

Migrating from API Key to Private App with VIDs

SOLVE

Thanks for the reply—I think for developers more experienced, your response likely was a helpful solution.

Let me try to simplify my noob question:

Since I'm adding the access_token to the header with `Authorization: Bearer`, can I simply remove the hapikey param from these existing links, turning this:

 

$url = 'https://api.hubapi.com/contacts/v1/contact?hapikey=' . $api_key;

 

  into

 

$url = 'https://api.hubapi.com/contacts/v1/contact';

 

(in essence, leaving the rest of the implementation in place, since after passing the access_token in the headers, that handles the authentication?)

Again, sorry if these are super basic questions!

0 Upvotes
ChehakWadhdwa
Solution
Member | Diamond Partner
Member | Diamond Partner

Migrating from API Key to Private App with VIDs

SOLVE

Hey  @MJProvencher

 

Yes, you can remove hapikey param from these existing links as these will be of no use from 1 December 2022 according to new privacy & policy changes of hubspot. All endpoints will rely on Private Apps that are the Authorization Bearer tokens.



Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

MJProvencher
Participant

Migrating from API Key to Private App with VIDs

SOLVE

In case it helps, this is a summary of what I needed to do:

 

define('HS_PRIVATE_APP_TOKEN', 'XXXXXX'); // added

$header = array(
	'Content-Type: application/json', // existing
	'Accept: application/json', // existing
	'Authorization: Bearer ' . HS_PRIVATE_APP_TOKEN  // needed to be added everywhere
);

// removed the following:
// $url = 'https://api.hubapi.com/companies/v2/companies/paged?hapikey='.$api_key.$properties.'&limit=200'.$hs_offset;

// added this modified declaration, removing the $api_key param
$url = 'https://api.hubapi.com/companies/v2/companies/paged?limit=200'.$properties.$hs_offset;

// and this was existing as well
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);	
0 Upvotes