Establishing a Connection
Authenticating to HubSpot
Connect via OAuth
HubSpot's API allows for authentication via OAuth. To authenticate using OAuth, leave these values blank to use the provider's embedded app.
Connect via API Key
To connect via Hubspot API Keys, set the APIKey property, and you are ready to connect.
Creating a Custom OAuth App
OAuth requires the authenticating user to interact with HubSpot using the browser. The provider facilitates this in various ways as described below.
Authenticate to HubSpot from a Desktop Application
After setting InitiateOAuth to GETANDREFRESH, you are ready to connect. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken connection property. When you connect the provider opens the OAuth endpoint in your default browser. Log in and grant permissions to the application. The provider then completes the OAuth process:
- Extracts the access token from the callback URL and authenticates requests.
- Refreshes the access token when it expires.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
Authenticate to HubSpot from a Web Application
When connecting via a Web application, or if the provider is not authorized to open a browser window, you need to exchange a verifier code for the access token.
To begin, you need to create an OAuth app with Hubspot and set the following connection properties.
- OAuthClientId: Set this to the client Id in your app settings.
- OAuthClientSecret: Set this to the client secret in your app settings.
Once you have created an app and set OAuthClientId and OAuthClientSecret you can exchange a verifier code for the access token.
- Call GetOAuthAuthorizationURL. The stored procedure returns the URL to the OAuth endpoint.
- Open the URL and log in. After granting permissions to the application, you are redirected back to the callback URL.
- The callback URL contains the verifier code in a query string parameter named "code". Extract the verifier code from the callback URL.
- Call GetOAuthAccessToken.
Accessing Custom Fields
If you have defined a large number of custom fields, SELECT * queries can fail with an error as HubSpot limits how many fields can be requested. To avoid the error, you can specify the custom fields you want to return in the text files specified by ContactPropertiesFile and DealPropertiesFile. Alternatively, specify the primary key in the WHERE clause.
If the detected column sizes for custom fields are not sufficient, you can specify the sizes in ColumnSizes.
Fine-Tuning Data Access
You can use the following properties to gain more control over column names:
Additionally, if you are making a desktop application, set CallbackURL to http://localhost when you connect. If you are making a Web application, set CallbackURL to a trusted URL where users will return after they authorize your application.
Connecting Through a Firewall or Proxy
To connect through the Windows system proxy, you do not need to set any additional connection properties. To connect to other proxies, set ProxyAutoDetect to false.
In addition, to authenticate to an HTTP proxy, set ProxyAuthScheme, ProxyUser, and ProxyPassword, in addition to ProxyServer and ProxyPort.
Set the following properties:
- To use a proxy-based firewall, set FirewallType, FirewallServer, and FirewallPort.
- To tunnel the connection, set FirewallType to TUNNEL.
- To authenticate, specify FirewallUser and FirewallPassword.
- To authenticate to a SOCKS proxy, additionally set FirewallType to SOCKS5.
Troubleshooting the Connection
To show provider activity from query execution to network traffic, use Logfile and Verbosity. The examples of common connection errors below show how to use these properties to get more context. Contact the support team for help tracing the source of an error or circumventing a performance issue.
- Authentication errors: Typically, recording a Logfile at Verbosity 4 is necessary to get full details on an authentication error.
- Queries time out: A server that takes too long to respond will exceed the provider's client-side timeout. Often, setting the Timeout property to a higher value will avoid a connection error. Another option is to disable the timeout by setting the property to 0. Setting Verbosity to 2 will show where the time is being spent.