<?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: How to access API using hubl in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/How-to-access-API-using-hubl/m-p/853832#M35982</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/406646"&gt;@jillii&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes you would, and this is where the serverless function/lambda comes into play. By running that request in a secure&amp;nbsp;environment that has&amp;nbsp;access to your auth you avoid security issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your flow would be something like:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;page loads&lt;/LI&gt;
&lt;LI&gt;module JS makes request to serverless function&lt;/LI&gt;
&lt;LI&gt;serverless function makes authentiated request to hubspot and return the needed data&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Fri, 22 Sep 2023 13:00:48 GMT</pubDate>
    <dc:creator>Kevin-C</dc:creator>
    <dc:date>2023-09-22T13:00:48Z</dc:date>
    <item>
      <title>How to access API using hubl</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-access-API-using-hubl/m-p/853362#M35958</link>
      <description>&lt;P&gt;Hello, I am trying to translate the following into hubl, so I can use it in a custom module. What this code does is it gets the current user's ID to extract data about them. Ultimately I am trying to figure out what Lists the current user is on.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;  $user_id = $_COOKIE['hubspotutk'];
  $url = "https://api.hubapi.com/contacts/v1/contact/utk/" . $user_id . "/profile";

  $curl = curl_init();
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_TIMEOUT, 10);
  curl_setopt($curl, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer pat-na1-XXXXX-XXX-XXX-XXXX-XXXXXX',
    'Content-Type: application/json'
  ]);

  $response = curl_exec($curl);
  $data = json_decode($response, true);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I've removed the autorization code for privacy.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 18:20:41 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-access-API-using-hubl/m-p/853362#M35958</guid>
      <dc:creator>jillii</dc:creator>
      <dc:date>2023-09-21T18:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to access API using hubl</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-access-API-using-hubl/m-p/853822#M35979</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/406646"&gt;@jillii&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So HUBL is a subset of Jinja, which is a templating language. By defenition templating languages do not have the ability to make http request. In your case you've got a few options:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;if the user is cookied via form you can use the HUBL {{ contact }} variable to access basic information about the contact like email, name, and id.&lt;/LI&gt;
&lt;LI&gt;you can use the ID from the above with JS to make an API call to a serverless function or external server to retrieve more data from the contact record&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would also nudge you to check out the available &lt;A href="https://developers.hubspot.com/docs/cms/hubl/functions" target="_blank"&gt;HUBL functions. &lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this gets you moving!&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 12:50:28 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-access-API-using-hubl/m-p/853822#M35979</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2023-09-22T12:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to access API using hubl</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-access-API-using-hubl/m-p/853825#M35980</link>
      <description>&lt;P&gt;This is a great answer. My only follow up question is: wouldn't I need my private app key to access data with an API call - in which case using js would make it available on the frontend? That seems like a huge security risk.. or am I missing something?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 12:57:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-access-API-using-hubl/m-p/853825#M35980</guid>
      <dc:creator>jillii</dc:creator>
      <dc:date>2023-09-22T12:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to access API using hubl</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-access-API-using-hubl/m-p/853832#M35982</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/406646"&gt;@jillii&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes you would, and this is where the serverless function/lambda comes into play. By running that request in a secure&amp;nbsp;environment that has&amp;nbsp;access to your auth you avoid security issues.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your flow would be something like:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;page loads&lt;/LI&gt;
&lt;LI&gt;module JS makes request to serverless function&lt;/LI&gt;
&lt;LI&gt;serverless function makes authentiated request to hubspot and return the needed data&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Fri, 22 Sep 2023 13:00:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-access-API-using-hubl/m-p/853832#M35982</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2023-09-22T13:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to access API using hubl</title>
      <link>https://community.hubspot.com/t5/CMS-Development/How-to-access-API-using-hubl/m-p/910080#M37559</link>
      <description>&lt;P&gt;Aha, that makes sense. Could you please provide an example of that workflow?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 14:15:32 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/How-to-access-API-using-hubl/m-p/910080#M37559</guid>
      <dc:creator>jillii</dc:creator>
      <dc:date>2024-01-23T14:15:32Z</dc:date>
    </item>
  </channel>
</rss>

