<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: hubspot crm api refresh token in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/hubspot-crm-api-refresh-token/m-p/903851#M70237</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/677352"&gt;@tjsimpson&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Based on my experience building HubSpot apps, HubSpot OAuth Refresh Tokens never expire.&lt;/P&gt;
&lt;P&gt;You'll either need to:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Immediately before each HubSpot API request (other than OAuth requests), use your refresh token to get a new access token (POST &lt;A href="https://api.hubapi.com/oauth/v1/token" target="_blank" rel="noopener"&gt;https://api.hubapi.com/oauth/v1/token&lt;/A&gt;, as per &lt;A href="https://developers.hubspot.com/docs/api/working-with-oauth" target="_blank" rel="noopener"&gt;this HubSpot documentation&lt;/A&gt;), or&lt;/LI&gt;
&lt;LI&gt;Store your access tokens and their expiry date in an external database. Then, before each HubSpot API request (other than OAuth requests), check to see if your existing access token is still valid. If not, use your refresh token to get a new one and update your database accordingly (including new access token expiry date).&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;I hope this proves useful. Please let me know if you have any follow-up questions.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Mar 2024 04:25:04 GMT</pubDate>
    <dc:creator>zach_threadint</dc:creator>
    <dc:date>2024-03-05T04:25:04Z</dc:date>
    <item>
      <title>hubspot crm api refresh token</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/hubspot-crm-api-refresh-token/m-p/899736#M70047</link>
      <description>&lt;P&gt;I am hoping to get some guidance on writing to the HubSpot CRM API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the following to pull data from HubSpot via Azure Data Factory:&lt;BR /&gt;&lt;STRONG&gt;Client ID&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Client Secret&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Access Token&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Refresh Token&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My understanding is the access_token expires every 30 minutes but the refresh_token will continue to refresh this. This connection has been working for 7 days now.&lt;BR /&gt;Does this refresh token expire? I have seen some places saying that it does not, and seeing it has worked for 7 days I am assuming this will continue to work.&lt;BR /&gt;&lt;BR /&gt;Now when I go to write to the HubSpot API have an issue where my access_token is expired. I would think there is a way to use the refresh_token in the API POST?&lt;BR /&gt;&lt;BR /&gt;Here is an example where I get the expiration response:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import hubspot
from pprint import pprint
from hubspot.crm.deals import BatchInputSimplePublicObjectInputForCreate, ApiException

client = hubspot.Client.create(
    access_token="placeholder"
    )


batch_input_simple_public_object_input_for_create = BatchInputSimplePublicObjectInputForCreate(inputs=[
    {"properties":
     {
         "dealname":"test"

         },
         "associations":
         [
             {"to":
              {
                  "id":"99999999999"},
              "types":
              [
                  {
                      "associationCategory":"HUBSPOT_DEFINED",
                      "associationTypeId":341
                      }]}]}])
try:
    api_response = client.crm.deals.batch_api.create(batch_input_simple_public_object_input_for_create=batch_input_simple_public_object_input_for_create)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling batch_api-&amp;gt;create: %s\n" % e)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;"status":"error","message":"The OAuth token used to make this call expired 5 day(s) ago."&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you in advance for your help!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2024 16:07:57 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/hubspot-crm-api-refresh-token/m-p/899736#M70047</guid>
      <dc:creator>tjsimpson</dc:creator>
      <dc:date>2024-01-02T16:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: hubspot crm api refresh token</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/hubspot-crm-api-refresh-token/m-p/903851#M70237</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/677352"&gt;@tjsimpson&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Based on my experience building HubSpot apps, HubSpot OAuth Refresh Tokens never expire.&lt;/P&gt;
&lt;P&gt;You'll either need to:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Immediately before each HubSpot API request (other than OAuth requests), use your refresh token to get a new access token (POST &lt;A href="https://api.hubapi.com/oauth/v1/token" target="_blank" rel="noopener"&gt;https://api.hubapi.com/oauth/v1/token&lt;/A&gt;, as per &lt;A href="https://developers.hubspot.com/docs/api/working-with-oauth" target="_blank" rel="noopener"&gt;this HubSpot documentation&lt;/A&gt;), or&lt;/LI&gt;
&lt;LI&gt;Store your access tokens and their expiry date in an external database. Then, before each HubSpot API request (other than OAuth requests), check to see if your existing access token is still valid. If not, use your refresh token to get a new one and update your database accordingly (including new access token expiry date).&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;I hope this proves useful. Please let me know if you have any follow-up questions.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2024 04:25:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/hubspot-crm-api-refresh-token/m-p/903851#M70237</guid>
      <dc:creator>zach_threadint</dc:creator>
      <dc:date>2024-03-05T04:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: hubspot crm api refresh token</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/hubspot-crm-api-refresh-token/m-p/904078#M70250</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811"&gt;@zach_threadint&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for the response! I was actually able to figure this out and forgot I had the post still up. I did exactly what you mention on option 1 and it works great.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Tyler Simpson&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2024 14:04:51 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/hubspot-crm-api-refresh-token/m-p/904078#M70250</guid>
      <dc:creator>tjsimpson</dc:creator>
      <dc:date>2024-01-11T14:04:51Z</dc:date>
    </item>
  </channel>
</rss>

