APIs & Integrations

jumpjumpjump
Member

Unable to get access_token using python

Using the example provided by your Python api doesn't seem to work. From the code below, I get the response `You must include a hapi_key or access_token attribute when initalizing the API.

 

 

 

from hubspot import HubSpot
try: 
  tokens = HubSpot().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 Exception as e: 
   print(e)

 

 

Any ideas why this might be happening?

 

0 Upvotes
3 Replies 3
JWirth
Member

Unable to get access_token using python

I had this issue when installing `hubspot` instead of `hubspot-api-python`.

0 Upvotes
taran42
Contributor

Unable to get access_token using python

I am not very familiar with getting HubSpot data via the OAuth method, but I do not see where you are referrencing your API key.  I'd start here for getting your data via OAuth.

 

You can also start here as a means to get your data with the API key, which I found more straightforward than OAuth.

dennisedson
HubSpot Product Team
HubSpot Product Team

Unable to get access_token using python

Hello @jumpjumpjump !

I am assuming the example code you are referencing is from here.

Wanted to makes sure you had also read over the oAuth documentation which can be found here

The quickstart guide details how to create the token here

 

Going to tag in @taran42 here who is I consider to be a python whiz 🙂

 

Thanks!

0 Upvotes