We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
May 19, 2022 12:01 PM
Hi 🙂
I have been trying to fetch data from Hubspot with Python and I am completely lost now. Hopefully someone can help 🙏
I have got the API key, created a test dev account, created an app, got the cliend id, the client secret, pip installed Hubspot in Anaconda and done this (code found in the documentation):
from hubspot import HubSpot
api_client = HubSpot(api_key='...')
from hubspot.auth.oauth import ApiException
try:
tokens = api_client.auth.oauth.default_api.create_token(
grant_type="authorization_code",
redirect_uri='http://localhost',
client_id='client_id',
client_secret='client_secret',
code='code'
)
except ApiException as e:
print("Exception when calling create_token method: %s\n" % e)
I am still missing the code that I have no idea how to find despite reading the documentation. AND I also get this error message which doesn't even seem linked to the missing code:
AttributeError: 'Discovery' object has no attribute 'default_api'
Can anyone help please?
Thanks a lot! Corentin
Solved! Go to Solution.
May 19, 2022 9:27 PM - edited May 19, 2022 9:28 PM
I believe we are doing similar things. If you are using Python, I also assume you are using the hubspot-client-api library.
If so, I would use your test account and create a private app there. Use the api and ability to accept the private app token. Unless you are developing for the marketplace, I suggest to keep it simple and go the private app route in your test account and then move your code to a private app in the production account.
May 20, 2022 6:25 AM
Hi Kevin, Hi Dennis,
thanks a lot for answering!
I did what you suggested @KMurray and I don't have an error message when doing so! 🙂
BUT When I try to call, for example:
api_client.crm.contacts.get_all()
I get an error message 😞
MaxRetryError: HTTPSConnectionPool(host='api.hubapi.com', port=443): Max retries exceeded with url: /crm/v3/objects/contacts?limit=100 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))
Any idea on what I am doing wrong here?
Thanks again! 🙏
Corentin
May 19, 2022 9:27 PM - edited May 19, 2022 9:28 PM
I believe we are doing similar things. If you are using Python, I also assume you are using the hubspot-client-api library.
If so, I would use your test account and create a private app there. Use the api and ability to accept the private app token. Unless you are developing for the marketplace, I suggest to keep it simple and go the private app route in your test account and then move your code to a private app in the production account.
May 19, 2022 4:47 PM
@JBeatty is a smart fellow and I think might be the right person to help you out here
Also, how do we feel about all the snake references in python 😬🐍
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |