APIs & Integrations

mario_sylvia
Member

How to authenticate using OAuth2 from a script?

Is there a way to use the hubspot OAuth2 API from a script? For example, I’m running a python script to retrieve Hubspot data and generate a report as text. I am able to use the apikey option to access data, but I’m not clear on how to use OAuth2 if I’m not within a webapp. The Hubspot Oauth2 examples I read on the Hubspot site all require the user to be logged into Hubspot.com before calling the OAuth2 API for authorization. How does one authenticate from a script in order to use the OAuth2 API correctly?

0 Upvotes
1 Reply 1
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

How to authenticate using OAuth2 from a script?

Hi @mario.sylvia,

OAuth 2 always requires a user to initiate the connection and receive the access/refresh tokens. After you’ve received the access/refresh tokens, your script can make requests with the access token without any user intervention.

0 Upvotes