APIs & Integrations

Jaycee_Lewis
Community Manager
Community Manager

Migration guide — Migrate an API key integration to a private app

Hey, HubSpot Developers! There are plenty of questions about the upcoming sunset and how to migrate your apps using API keys to use Private Apps.

 

Luckily, our amazing team put together this guide, Migrate an API key integration to a private app 

 

Changelog information here — Upcoming: API Key Sunset

 

If you have questions about the guide or the information included, please leave your feedback in the comments. If you have specific questions about migration of your app, please consider starting a new thread. This will help make sure your request gets the attention it deserves from our community. 

 

Have fun coding! — Jaycee 🧡

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

29 Replies 29
KLockhart
Member

Migration guide — Migrate an API key integration to a private app

Hello - I know we are at the dead line but I cannot get this to work. I am not a developer and inherited this from a former coworker. I barely know python which is what we are using to create a contact file that then gets imported into hubspot. I made changes that I thought were obvious in the script (liek commenting ou the api parts and pasting in the code from the python sections in the migration guide). My code runs and the output gives me a 401 error in my results file. It does not show as any calls in the private app itself but one time did show in the api call log as a 400 error. The instructions are all so confusing  and even the video using postman is of no help to me. Can anyone help me?

 

0 Upvotes
KLockhart
Member

Migration guide — Migrate an API key integration to a private app

This is where the old file used to refer back to the section where had api key file and then added these few lines.  I have tried every variation of this (of course putting in my access token where it says access token)  - I have used single quotes around the access token, around the % and the access token, substituted the access token in same section where it says bearer. Nothing works. How am I supposed to enter it? Is this all I should need in addition to removing the api key references everywhere?  The querystring actually feeds into the webhook as a parameter so I feel I need to put something about the token there but not sure if I just do it all there or before there or what? Am I even on the right track? We are using the endpoint of  https://api.hubapi.com/contacts/v1/contact/batch

 

KLockhart_0-1669835307847.png

 

0 Upvotes
Sylvain_T
Participant

Migration guide — Migrate an API key integration to a private app

Hello,
We finaly got to go (about time) from our client to modify our CMS to their Hupspot connection, from api to APP key. We created the APP and gave the proper accesses. We developped on PHP and it looks like just modifying 
```

$this->_hubSpot = \HubSpot\Factory::createWithApiKey(getenv('HB_KEY'))
```
TO
¨¨ 
$this->_hubSpot = \HubSpot\Factory::createWithAccessToken(getenv('HB_APP'))
```
(Changing the environment key from the API to the new APP) does the trick. It seems, to simple to be true... I mean I tested to extract Contact and related Deals and sure enough it works. SHould I expect surprises on December 1st or am I good ?

0 Upvotes
srozentsvayg
Member

Migration guide — Migrate an API key integration to a private app

Hey

Following api keys migration to private app .

we created 3 custome objects in hubspot and populate them by python rest to /crm/v3/imports api (csv load)

On the old Api key its work but when i am using private app i getting error , the old and private app have the same Scope, please help

 

{"status":"error","message":"The API key provided is invalid. View or manage your API key here: https://app.hubspot.com/l/api-key/","correlationId":"10aecca7-6eb3-490b-9808-195862ee1a58","category":"INVALID_AUTHENTICATION","links":{"api key":"https://app.hubspot.com/l/api-key/"}}

0 Upvotes
DevHubSFDC
Member

Migration guide — Migrate an API key integration to a private app

Hey, 
In the previous method, we did integration from hubspot to SFDC, and that all was through managed package in Salesforce and without any custom code.
HubSpot API key was residing in HubSpot account Integration tab.

Now when this is going to sunset and new method is coming up, what should be our step for Integration of HubSpot with Saleforce?
Either this will work directly through SubSpot Account or we need to do some changes in Salesforce configuration as well?
Like to use any custom code to use new authentication method? or it will be directly through the package upgrade in salesforce?

0 Upvotes
CLebleu
Member

Migration guide — Migrate an API key integration to a private app

Hi! I'm a developer, but not familiar with Hubspot. I'm making a website for a client with a contact form, and I need the form submissions to go into Hubspot. 

 

The website is made with Gatsby, and there's this handy plugin to add forms. However, the plugin requires an API key, which apparently I can no longer create.

 

I'm trying to go through the migration guide, and I'm not sure if I should go with a private app or with OAuth. What's the recommended workflow for this situation?

Alternatively, is there a simple way to set up a webhook to receive the form submissions? The website is published through Netlify, where I can add an outgoing webhook on every form submission. All it needs is a URL to notify, and an optional JWS secret token.

JSaportas
Member

Migration guide — Migrate an API key integration to a private app

Hello

Using C#  httpclient using hapikey an exmple url request looks like this:

"https://api.hubapi.com/crm/v3/objects/companies?archived=false&limit=100&properties=name&hapikey=my...

Couldnt find any example on how to change it to work with the new private app 

need help thanks

 

0 Upvotes
DStreem
Participant

Migration guide — Migrate an API key integration to a private app

I'm trying to follow the migration plan, but am running into an issue.

 

The migration guide recommends the following:

 


Follow the steps below to migrate an existing API key integration to a private app. It's recommended you first use a test environment, such as a developer test account or sandbox account, before making changes in production.

Can you please share how to follow the migration plan using a Developer Test Account? It doesn't appear to be possible to create private apps using this type of account. Users with Super Admin privileges do not have permission to view the Private Apps page. Is there a way around this?

 

When we reached out to Hubspot Support, they shared the following:

 

The private apps are only intended to be shown on the live portals as they are portal specific connections where the developer portals create apps that could be used in more than one portal if desired. If you are looking for a testing type environment where you can test things like creating a private app that would be something you would do through a Sandbox account. This does require an enterprise level subscription in one of the hubs to have access to this.


We do not have an enterprise Hubspot account so can't create a Sandbox.

 

Would really appreciate some help on this. Thank you.

0 Upvotes
DStreem
Participant

Migration guide — Migrate an API key integration to a private app

Update -- I figured out how to create a Private App from my Developer Test account.

 

In my case, a user with Super Admin privileges runs into this error:

Screen Shot 2022-10-13 at 2.51.49 PM.png

But the original account creator is able to create private apps:

Screen Shot 2022-10-14 at 10.29.41 AM.png

0 Upvotes
LKlaßen
Participant

Migration guide — Migrate an API key integration to a private app

Hello,

 

I have a question relating to this topic. 
We have to change our custom code in workflows (python) from Key to Token.
In my console, the code works fine. Easy to change, but in the workflow I get an Error.

console:


 

from hubspot import HubSpot
from hubspot.crm.quotes import ApiException

hubspot = HubSpot(access_token=token)
hubspot.crm.quotes.associations_api.get_all(quote_id="56948949", to_object_type="deal", limit=1)​

-> 
{'paging': None, 'results': [{'id': '5529167352', 'type': 'quote_to_deal'}]}

 

workflow

 

from hubspot import HubSpot
from hubspot.crm.quotes import ApiException

hubspot = HubSpot(access_token=os.getenv("HTOKEN"))
hubspot.crm.quotes.associations_api.get_all(quote_id="56948949", to_object_type="deal", limit=1)

->
[ERROR] ApiException: (401)
Reason: Unauthorized
HTTP response body: {"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":"a166f3d7-1fb9-46f5-a7cf-9fee0787b985","category":"INVALID_AUTHENTICATION"}

 

0 Upvotes
Vivre
Participant

Migration guide — Migrate an API key integration to a private app

This might be a stupid question sorry (not a developer) - this migration wont affect any public apps installed right? i.e from the Marketplace

0 Upvotes
JOConnell2
Member

Migration guide — Migrate an API key integration to a private app

How do HubL calls authenticate? I have changed our severless functions to use the authorisation header with the access code from our private app and i have changed our calls that use the client libraries to use the access code also.

 

I cannot find out how to change the authorization method of my HubL calls present in our dynamic pages. I can see from the API logs that the HubL calls continue to use the old API key.

0 Upvotes
JOConnell2
Member

Migration guide — Migrate an API key integration to a private app

Hi,

 

I have migrated our serverless functions over to using a private app by including the Authorisation header and have updated the Hubspot Client Library calls to include the access token of the new private app.

 

What i don't know how to do is change the call made by HubL functions within our HTML, for example:

 

{% set contacts = crm_associations(propertyID, "USER_DEFINED", ASSOCIATION_TYPE_CONTACT_TO_COMAPNY, "","phone,firstname,lastname,email,ownership_status,customer_services_owner") %}

 

When I check the logs I see traffic coming in using the old API key, where is the authorisastion for this function set?

 

Regards,

Jordan

 

0 Upvotes
NHalim
Member

Migration guide — Migrate an API key integration to a private app

Hi,

 

Can the access token of Private App be rotated by manual interaction only?

Does it have refresh token to regenerate token?

 

Many thanks!

0 Upvotes
JOrtuno
Member

Migration guide — Migrate an API key integration to a private app

Hi HubSpot Developers 🙂,

 

I have a similar problem as others when using a method from the V1 version:

https://api.hubapi.com/integrations/v1/limit/daily

Even though the Private App that we created was allowing the access to every scope.

The message error is the following: "The scope needed for this API call isn't available for public use. If you have questions, contact support or post in our developer forum."

 

Thanks for your time!

 

 

0 Upvotes
GustavoOliveira
Participant

Migration guide — Migrate an API key integration to a private app

Hi, we are preparing to move to the new method. On the Article Guide it directs to the V3 API Enpoints.
My question is, on the required method, Private Apps, is the only possible API available for the new method the V3 API?

One of the features only possible in the V1 API is the Property History, and we wanted to keep this feature after the change.

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Migration guide — Migrate an API key integration to a private app

Hey, @GustavoOliveira 👋 I am happy to check for us.

 

Can you tell me specifically which v1 API you are referring to? For example, the Get a contact by vid endpoint works with private apps.

 

Thank you! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
GustavoOliveira
Participant

Migration guide — Migrate an API key integration to a private app

Thanks!

 

It's the Get all deals (hubspot.com) or Get a deal | Deals API (hubspot.com) enpoints. But specifcally the parameters to get all version of a property ("Properties with History" and "Include property versions", respectively), which is something the newer APIs don't seem to provide.

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Migration guide — Migrate an API key integration to a private app

Hey, @GustavoOliveira 👋 Thank you very much for clarifying. I successfully ran quick tests of both v1 endpoints using Postman and included the additional params:

Get all deals

  • Endpoint 
    GET https://api.hubapi.com/deals/v1/deal/paged?propertiesWithHistory=dealname​
  • Response (edited to only include the relevant Deal)
    {
                "portalId": 22245342,
                "dealId": 9669508372,
                "isDeleted": false,
                "associations": null,
                "properties": {
                    "dealname": {
                        "value": "Changer v2",
                        "timestamp": 1659390587045,
                        "source": "CRM_UI",
                        "sourceId": "userId:10233975",
                        "updatedByUserId": 10233975,
                        "versions": [
                            {
                                "name": "dealname",
                                "value": "Changer v2",
                                "timestamp": 1659390587045,
                                "sourceId": "userId:10233975",
                                "source": "CRM_UI",
                                "sourceVid": [],
                                "updatedByUserId": 10233975
                            },
                            {
                                "name": "dealname",
                                "value": "Changer v1",
                                "timestamp": 1659390567632,
                                "source": "CRM_UI",
                                "sourceVid": [],
                                "updatedByUserId": 10233975
                            }
                        ]
                    }
                },
                "stateChanges": []
            }
        ],
        "hasMore": false,
        "offset": 9669508373​

Get a deal

  • Endpoint 
    GET https://api.hubapi.com/deals/v1/deal/9669508372?includePropertyVersions=true​
  • Response (edited to include only the relevant deal property)
    "dealname": {
                "value": "Changer v2",
                "timestamp": 1659390587045,
                "source": "CRM_UI",
                "sourceId": "userId:10233975",
                "updatedByUserId": 10233975,
                "versions": [
                    {
                        "name": "dealname",
                        "value": "Changer v2",
                        "timestamp": 1659390587045,
                        "sourceId": "userId:10233975",
                        "source": "CRM_UI",
                        "sourceVid": [],
                        "updatedByUserId": 10233975
                    },
                    {
                        "name": "dealname",
                        "value": "Changer v1",
                        "timestamp": 1659390567632,
                        "source": "CRM_UI",
                        "sourceVid": [],
                        "updatedByUserId": 10233975
                    }
                ]
            },​

Thank you for asking this question. It helps other community members as well as helping us identify areas where more clarity is needed.

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

GustavoOliveira
Participant

Migration guide — Migrate an API key integration to a private app

Thank you so much for the answer, it's really thorough.

 

Now it's clear that I can make this change.