Python Connector for HubSpot

Connecting to HubSpot - Python Connector for HubSpot

Connecting to HubSpot

To establish a connection to HubSpot, import the connector and authenticate using basic or OAuth 2.0 authentication.

Step 1. Import the connector

First, import the HubSpot connector module:

import devart.hubspot as hubspot

Step 2. Establish a connection

Connect to your HubSpot account using the connect() module method and obtain a connection object.

You can connect to HubSpot using API key, access token, or OAuth 2.0 authentication.

API key authentication

For API key authentication, provide your HubSpot API key:

my_connection = hubspot.connect(
    Authentication="APIKey",
APIKey="your_api_key" )

Replace the example value with your actual API key.

For more information, see Connection parameters.

Access token authentication

For access token authentication, provide your HubSpot access token:

my_connection = hubspot.connect(
    Authentication="PrivateApp",
    AccessToken="your_access_token"
)

Replace the example value with your actual access token.

For more information, see Connection parameters.

OAuth 2.0 authentication

For OAuth 2.0 authentication, first obtain a refresh token, then use it to establish the connection:

response = devart.hubspot.signin()
my_connection = hubspot.connect(
    Authentication="OAuth",
    RefreshToken=response["Refresh Token"]
)

Replace the example values with your actual refresh token.

For more information, see Connection parameters.

© 2022-2026 Devart. All Rights Reserved. Request Support Python Connectors Forum Provide Feedback