APIs & Integrations

MJProvencher
参加者

Migrating from API Key to Private App with VIDs

解決

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件の承認済みベストアンサー
MJProvencher
解決策
参加者

Migrating from API Key to Private App with VIDs

解決

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 いいね!
ChehakWadhdwa
解決策
メンバー | Diamond Partner
メンバー | Diamond Partner

Migrating from API Key to Private App with VIDs

解決

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.

元の投稿で解決策を見る

4件の返信
ChehakWadhdwa
メンバー | Diamond Partner
メンバー | Diamond Partner

Migrating from API Key to Private App with VIDs

解決

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
解決策
参加者

Migrating from API Key to Private App with VIDs

解決

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 いいね!
ChehakWadhdwa
解決策
メンバー | Diamond Partner
メンバー | Diamond Partner

Migrating from API Key to Private App with VIDs

解決

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
参加者

Migrating from API Key to Private App with VIDs

解決

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 いいね!