Oauth authentication for posting to Contacts api

oauth

#1

I’m attempting to write a headless program for posting to the contacts API. I’ve been successful in doing this using hapikey authentication but I prefer to use Oauth.

I am able to retrieve access and refresh tokens from https://api.hubapi.com/oauth/v1/token but this requires user action to choose an account and retrieve the code from the authorization url (https://app.hubspot.com/oauth/authorize?client_id=3333&scope=contacts%20automation&redirect_uri=https://www.example.com/)

Has anyone been successful in retrieving access tokens from the token api without user input?


#2

Figured this out with a little help from our Hubspot tech.

In case anyone runs into a similar issue, the refresh token returned from the initial API token call should be used to get new access tokens from the token API. Getting the code from the authorization url is only necessary for the initial authorization.