<?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: Integration of Google API into Qlik Sense data connection in Integration, Extension &amp; APIs</title>
    <link>https://community.qlik.com/t5/Integration-Extension-APIs/Integration-of-Google-API-into-Qlik-Sense-data-connection/m-p/2071590#M18558</link>
    <description>&lt;P&gt;Hey Darren and JB!&lt;/P&gt;
&lt;P&gt;Here's how I would do it:&lt;/P&gt;
&lt;H2&gt;Step 1: Create a new credential in Google Cloud&lt;/H2&gt;
&lt;P&gt;Follow step 1 in &lt;A href="https://blog.postman.com/how-to-access-google-apis-using-oauth-in-postman/" target="_blank" rel="noopener"&gt;this guide&lt;/A&gt; on using Postman to make authenticated OAuth calls to the Google APIs. You should use &lt;A href="https://postman.com" target="_blank" rel="noopener"&gt;Postman&lt;/A&gt; to make this whole process way easier, as it is a API testing tool with an easy-to-use interface.&lt;/P&gt;
&lt;P&gt;The above guide starts off with creating a project in Google Cloud -- you probably can use an existing one, hopefully your team has some foresight into that. Once an existing project is chosen or a new one is created, you should select and enable the requisite API product. The guide uses the Google Sheets API for its example, however you will want to find and enable the &lt;A href="https://console.cloud.google.com/apis/library/licensing.googleapis.com" target="_blank" rel="noopener"&gt;Enterprise License Manager API&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Access Google API - MD DoIT - 2.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107222i989775576FB0E3CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Access Google API - MD DoIT - 2.png" alt="Access Google API - MD DoIT - 2.png" /&gt;&lt;/span&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Follow step 2 of the guide. When it gets to the part about adding scopes, find the&amp;nbsp;&lt;STRONG&gt;Manually add scopes&lt;/STRONG&gt; section and then add this scope:&lt;/P&gt;
&lt;PRE data-unlink="true"&gt;https://www.googleapis.com/auth/apps.licensing&lt;/PRE&gt;
&lt;P&gt;It should look like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Access Google API - MD DoIT - 3.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107223i276989F228FE31CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Access Google API - MD DoIT - 3.png" alt="Access Google API - MD DoIT - 3.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finish step 2 of the guide. Once you get to step 3, jump ahead to the part where it tells you to "&lt;SPAN&gt;navigate to the&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Authorization&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;tab in your Postman account and select&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;OAuth 2.0&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;as your authorization type."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P data-unlink="true"&gt;Remember to use &lt;STRONG&gt;https://www.googleapis.com/auth/apps.licensing&lt;/STRONG&gt;&amp;nbsp;as the scope for that step!&lt;/P&gt;
&lt;P data-unlink="true"&gt;Also, make sure to follow the note in this section:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AustinSpivey_0-1684186572090.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107224i4EC899C896CF5DAE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AustinSpivey_0-1684186572090.png" alt="AustinSpivey_0-1684186572090.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As it directs, make sure to use this as your&amp;nbsp;&lt;STRONG&gt;Auth URL&lt;/STRONG&gt;:&lt;/P&gt;
&lt;PRE data-unlink="true"&gt;https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&lt;/PRE&gt;
&lt;P&gt;Once you follow all of the step 3, you should now have your token (which should start with something like&amp;nbsp;&lt;STRONG&gt;ya29&lt;/STRONG&gt; or whatever).&amp;nbsp;&lt;STRONG&gt;NOTE:&amp;nbsp;&lt;/STRONG&gt; you will also need the provided Refresh Token as well later on, so you should keep both on hand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Step 2: Create the&amp;nbsp;&lt;SPAN&gt;Enterprise License Manager API data connection in Qlik&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;At this point, we can now create our data connection in Qlik. Rather than using any of the out-of-the-box Google connectors, we'll actually just use the REST connector to achieve this. Here's how to set it up:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;URL:&amp;nbsp;&lt;A href="https://licensing.googleapis.com/apps/licensing/v1/product/Google-Apps/users" target="_blank"&gt;https://licensing.googleapis.com/apps/licensing/v1/product/Google-Apps/users&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Certificate validation: Skip Server Certificate Validation&lt;/LI&gt;
&lt;LI&gt;Query parameters:
&lt;UL&gt;
&lt;LI&gt;customerId | *Put your Google customer ID here. &lt;A href="https://support.google.com/cloudidentity/answer/10070793?hl=en" target="_blank" rel="noopener"&gt;Here's a help page&lt;/A&gt; if you don't know what it is.*&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;Query headers:
&lt;UL&gt;
&lt;LI&gt;Authorization |&amp;nbsp;Bearer *your token here*&lt;/LI&gt;
&lt;LI&gt;Accept |&amp;nbsp;application/json&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;span class="lia-unicode-emoji" title=":ballot_box_with_check:"&gt;☑️&lt;/span&gt; Add missing query parameters to final request&lt;/LI&gt;
&lt;LI&gt;Security
&lt;UL&gt;
&lt;LI&gt;&lt;span class="lia-unicode-emoji" title=":ballot_box_with_check:"&gt;☑️&lt;/span&gt; Allow HTTPS only&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AustinSpivey_1-1684187131601.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107226i9E458C528B117956/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AustinSpivey_1-1684187131601.png" alt="AustinSpivey_1-1684187131601.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;That URL above uses&amp;nbsp;&lt;STRONG&gt;/Google-Apps/&lt;/STRONG&gt; but you can use any of the licensed products found on &lt;A href="https://developers.google.com/admin-sdk/licensing/v1/how-tos/products" target="_blank" rel="noopener"&gt;this help page&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Name it something appropriate and then save.&lt;/P&gt;
&lt;P&gt;Now when you load it, you should be able to see those license assignments:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AustinSpivey_2-1684187394837.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107227iD3CCA19C0BC97A56/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AustinSpivey_2-1684187394837.png" alt="AustinSpivey_2-1684187394837.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Step 3: Add script for getting new refreshing the access tokens&lt;/H2&gt;
&lt;P&gt;We were able to use Postman to get our initial access token in step 1 of this post, but you will need to account for that token, and future ones, expiring after about an hour. Here's some Qlik script that you can use to achieve this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// ===================================================================
//  GET NEW TOKEN
// ===================================================================

SUB GetGoogleToken
    LIB CONNECT TO 'Google Refresh Token';

    [Refresh Token Response]:
    SQL SELECT 
        "access_token",
        "expires_in",
        "scope",
        "token_type"
    FROM JSON (wrap on) "root";

    [Refresh Token]:
    LOAD
        Now() as [token_acquired_ts],
        [access_token],
        [expires_in],
        [scope],
        [token_type]
    RESIDENT [Refresh Token Response];
    DROP TABLE [Refresh Token Response];
    
    Store [Refresh Token] into 'lib://DataFiles/google_token.qvd'(QVD);
    Let vToken = peek('access_token', 0, 'Refresh Token');
    Drop Table [Refresh Token];
END SUB


// ===================================================================
//  TOKEN CHECK
// ===================================================================

SUB TokenCheck
    Let vNow = Now();
    Let vQVD_ts = Coalesce(timestamp#( QvdCreateTime('lib://DataFiles/google_token.qvd')  + (60/60/24) - ((60/60/24/60/60)*5) ), 0);
    Let vCompare = timestamp('$(vNow)') &amp;gt; timestamp('$(vQVD_ts)');
    
    IF timestamp(Now()) &amp;gt; timestamp(Coalesce( QvdCreateTime('lib://DataFiles/google_token.qvd')  + (60/60/24) - ((60/60/24/60/60)*5), 0) ) THEN
        Trace #### Graph token expired...getting new token now.;
        Call GetGoogleToken
    ELSE
        Trace #### Graph token still good.;
        
        [Access Token]: LOAD [access_token] FROM 'lib://DataFiles/google_token.qvd'(QVD);
        Let vToken = peek('access_token', 0, 'Access Token');
        Drop Table [Access Token];
    END IF
END SUB&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order for this script to work, you will need to create another REST connection in Qlik, like so:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;URL:&amp;nbsp;&lt;A href="https://oauth2.googleapis.com/token" target="_blank"&gt;https://oauth2.googleapis.com/token&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Method: POST&lt;/LI&gt;
&lt;LI&gt;Request body:&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;client_id=whatever-your-client-id-is.apps.googleusercontent.com&amp;amp;client_secret=whatever-your-client-secret-is&amp;amp;refresh_token=whatever-your-refresh-token-is&amp;amp;grant_type=refresh_token&lt;/PRE&gt;
&lt;UL&gt;
&lt;LI&gt;Query headers:
&lt;UL&gt;
&lt;LI&gt;Content-Type |&amp;nbsp;application/x-www-form-urlencoded&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;Security
&lt;UL&gt;
&lt;LI&gt;&lt;span class="lia-unicode-emoji" title=":ballot_box_with_check:"&gt;☑️&lt;/span&gt; Allow HTTPS only&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should result in a new access token that Qlik can use to continue getting the Google licensing info, at least until the refresh token itself expires (not sure what the default it, that may be set by organization policy).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Notes about the Qlik script&lt;/H2&gt;
&lt;P&gt;That script has been tested and logically works, but my implementation may be a bit tortured or lazy in some ways, just an FYI. It uses &lt;A href="https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/Sub.htm" target="_blank" rel="noopener"&gt;Subroutines&lt;/A&gt; to define reusable procedures called&amp;nbsp;&lt;STRONG&gt;GetGoogleToken&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;TokenCheck&lt;/STRONG&gt; (if you're unfamiliar with subroutines, they're basically like functions you write in Qlik). You can use those subroutines like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CALL TokenCheck;

LIB CONNECT TO 'Google Licensing 1';

RestConnectorMasterTable:
SQL SELECT 
	"kind" AS "kind_u0",
	"etag",
	"__KEY_root",
	(SELECT 
		"kind",
		"etags",
		"productId",
		"userId",
		"selfLink",
		"skuId",
		"skuName",
		"productName",
		"__FK_items"
	FROM "items" FK "__FK_items")
FROM JSON (wrap on) "root" PK "__KEY_root"

  WITH CONNECTION (
    HTTPHEADER "Authorization" "Bearer $(vToken)"
);

[items]:
LOAD
	[kind],
	[etags],
	[productId],
	[userId],
	[selfLink],
	[skuId],
	[skuName],
	[productName],
	[__FK_items] AS [__KEY_root]
RESIDENT RestConnectorMasterTable
  WHERE NOT IsNull([__FK_items])
;

[root]:
LOAD
	[kind_u0] AS [kind_u0],
	[etag],
	[__KEY_root]
RESIDENT RestConnectorMasterTable
  WHERE NOT IsNull([__KEY_root])
;

DROP TABLE RestConnectorMasterTable;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The script above will:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Call the&amp;nbsp;&lt;STRONG&gt;TokenCheck&lt;/STRONG&gt; subroutine, which will get the token that we have stored to a QVD and check to see if it's expired -- if it&amp;nbsp;&lt;STRONG&gt;is&lt;/STRONG&gt; expired, it calls the&amp;nbsp;GetGoogleToken subroutine to go refresh that token and get a new one, which gets stored back to that same QVD. It will then set that token value to a variable called&amp;nbsp;&lt;STRONG&gt;vToken&lt;/STRONG&gt;. If, however, the token in the QVD is&amp;nbsp;&lt;STRONG&gt;not&lt;/STRONG&gt; expired, it will simply set it to the&amp;nbsp;&lt;STRONG&gt;vToken&amp;nbsp;&lt;/STRONG&gt;variable.&lt;/LI&gt;
&lt;LI&gt;Now that we have our token, we use the&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/cloud-services/Subsystems/REST_Connector_help/Content/Connectors_REST/Load-REST-data/Load-data.htm#anchor-5" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;WITH CONNECTION&lt;/STRONG&gt; command&lt;/A&gt; to dynamically update our&amp;nbsp;&lt;STRONG&gt;Authorization&lt;/STRONG&gt; header with our unexpired token using the&amp;nbsp;&lt;STRONG&gt;vToken&lt;/STRONG&gt; variable.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Further enhancements to this process&lt;/H2&gt;
&lt;P&gt;You could take this all a step further by looping through the &lt;A href="https://developers.google.com/admin-sdk/licensing/v1/how-tos/products" target="_blank" rel="noopener"&gt;list of Google products&lt;/A&gt; to get the license use for all of your relevant products.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 May 2023 22:16:33 GMT</pubDate>
    <dc:creator>AustinSpivey</dc:creator>
    <dc:date>2023-05-15T22:16:33Z</dc:date>
    <item>
      <title>Integration of Google API into Qlik Sense data connection</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Integration-of-Google-API-into-Qlik-Sense-data-connection/m-p/2069823#M18542</link>
      <description>&lt;P&gt;We are attempting to pull in the &lt;STRONG&gt;Google Enterprise licensing API and create a data connection in Qlik Sense Enterprise for Windows&lt;/STRONG&gt;. Our goal is to visualize the Google Enterprise license usage in a Qlik Sense Dashboard. Can anyone provide the necessary steps for this connection?&lt;/P&gt;
&lt;P&gt;Currently we have Qlik Web Connectors service running using the instructions found &lt;A href="https://help.qlik.com/en-US/connectors/Subsystems/Web_Connectors_help/Content/Connectors_QWC/Administer/administer_home.htm" target="_self"&gt;here&lt;/A&gt; however this is still a work in progress. The&amp;nbsp;Qlik Web Connectors service is related to an effort to create a Google Drive &amp;amp; Spreadsheets connector. I am not sure if there is any overlap with Google Enterprise licensing API connector and creating the Google Drive &amp;amp; Spreadsheets connector. But I thought it was worth mentioning&lt;/P&gt;
&lt;P&gt;Thanks in advance for any assistance&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/132444"&gt;@jbchurchill&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 17:11:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Integration-of-Google-API-into-Qlik-Sense-data-connection/m-p/2069823#M18542</guid>
      <dc:creator>Darren1</dc:creator>
      <dc:date>2023-05-10T17:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: Integration of Google API into Qlik Sense data connection</title>
      <link>https://community.qlik.com/t5/Integration-Extension-APIs/Integration-of-Google-API-into-Qlik-Sense-data-connection/m-p/2071590#M18558</link>
      <description>&lt;P&gt;Hey Darren and JB!&lt;/P&gt;
&lt;P&gt;Here's how I would do it:&lt;/P&gt;
&lt;H2&gt;Step 1: Create a new credential in Google Cloud&lt;/H2&gt;
&lt;P&gt;Follow step 1 in &lt;A href="https://blog.postman.com/how-to-access-google-apis-using-oauth-in-postman/" target="_blank" rel="noopener"&gt;this guide&lt;/A&gt; on using Postman to make authenticated OAuth calls to the Google APIs. You should use &lt;A href="https://postman.com" target="_blank" rel="noopener"&gt;Postman&lt;/A&gt; to make this whole process way easier, as it is a API testing tool with an easy-to-use interface.&lt;/P&gt;
&lt;P&gt;The above guide starts off with creating a project in Google Cloud -- you probably can use an existing one, hopefully your team has some foresight into that. Once an existing project is chosen or a new one is created, you should select and enable the requisite API product. The guide uses the Google Sheets API for its example, however you will want to find and enable the &lt;A href="https://console.cloud.google.com/apis/library/licensing.googleapis.com" target="_blank" rel="noopener"&gt;Enterprise License Manager API&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Access Google API - MD DoIT - 2.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107222i989775576FB0E3CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Access Google API - MD DoIT - 2.png" alt="Access Google API - MD DoIT - 2.png" /&gt;&lt;/span&gt; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Follow step 2 of the guide. When it gets to the part about adding scopes, find the&amp;nbsp;&lt;STRONG&gt;Manually add scopes&lt;/STRONG&gt; section and then add this scope:&lt;/P&gt;
&lt;PRE data-unlink="true"&gt;https://www.googleapis.com/auth/apps.licensing&lt;/PRE&gt;
&lt;P&gt;It should look like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Access Google API - MD DoIT - 3.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107223i276989F228FE31CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Access Google API - MD DoIT - 3.png" alt="Access Google API - MD DoIT - 3.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finish step 2 of the guide. Once you get to step 3, jump ahead to the part where it tells you to "&lt;SPAN&gt;navigate to the&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Authorization&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;tab in your Postman account and select&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;OAuth 2.0&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;as your authorization type."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P data-unlink="true"&gt;Remember to use &lt;STRONG&gt;https://www.googleapis.com/auth/apps.licensing&lt;/STRONG&gt;&amp;nbsp;as the scope for that step!&lt;/P&gt;
&lt;P data-unlink="true"&gt;Also, make sure to follow the note in this section:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AustinSpivey_0-1684186572090.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107224i4EC899C896CF5DAE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AustinSpivey_0-1684186572090.png" alt="AustinSpivey_0-1684186572090.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As it directs, make sure to use this as your&amp;nbsp;&lt;STRONG&gt;Auth URL&lt;/STRONG&gt;:&lt;/P&gt;
&lt;PRE data-unlink="true"&gt;https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&lt;/PRE&gt;
&lt;P&gt;Once you follow all of the step 3, you should now have your token (which should start with something like&amp;nbsp;&lt;STRONG&gt;ya29&lt;/STRONG&gt; or whatever).&amp;nbsp;&lt;STRONG&gt;NOTE:&amp;nbsp;&lt;/STRONG&gt; you will also need the provided Refresh Token as well later on, so you should keep both on hand.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Step 2: Create the&amp;nbsp;&lt;SPAN&gt;Enterprise License Manager API data connection in Qlik&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;At this point, we can now create our data connection in Qlik. Rather than using any of the out-of-the-box Google connectors, we'll actually just use the REST connector to achieve this. Here's how to set it up:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;URL:&amp;nbsp;&lt;A href="https://licensing.googleapis.com/apps/licensing/v1/product/Google-Apps/users" target="_blank"&gt;https://licensing.googleapis.com/apps/licensing/v1/product/Google-Apps/users&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Certificate validation: Skip Server Certificate Validation&lt;/LI&gt;
&lt;LI&gt;Query parameters:
&lt;UL&gt;
&lt;LI&gt;customerId | *Put your Google customer ID here. &lt;A href="https://support.google.com/cloudidentity/answer/10070793?hl=en" target="_blank" rel="noopener"&gt;Here's a help page&lt;/A&gt; if you don't know what it is.*&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;Query headers:
&lt;UL&gt;
&lt;LI&gt;Authorization |&amp;nbsp;Bearer *your token here*&lt;/LI&gt;
&lt;LI&gt;Accept |&amp;nbsp;application/json&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;span class="lia-unicode-emoji" title=":ballot_box_with_check:"&gt;☑️&lt;/span&gt; Add missing query parameters to final request&lt;/LI&gt;
&lt;LI&gt;Security
&lt;UL&gt;
&lt;LI&gt;&lt;span class="lia-unicode-emoji" title=":ballot_box_with_check:"&gt;☑️&lt;/span&gt; Allow HTTPS only&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AustinSpivey_1-1684187131601.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107226i9E458C528B117956/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AustinSpivey_1-1684187131601.png" alt="AustinSpivey_1-1684187131601.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;That URL above uses&amp;nbsp;&lt;STRONG&gt;/Google-Apps/&lt;/STRONG&gt; but you can use any of the licensed products found on &lt;A href="https://developers.google.com/admin-sdk/licensing/v1/how-tos/products" target="_blank" rel="noopener"&gt;this help page&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Name it something appropriate and then save.&lt;/P&gt;
&lt;P&gt;Now when you load it, you should be able to see those license assignments:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AustinSpivey_2-1684187394837.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/107227iD3CCA19C0BC97A56/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AustinSpivey_2-1684187394837.png" alt="AustinSpivey_2-1684187394837.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Step 3: Add script for getting new refreshing the access tokens&lt;/H2&gt;
&lt;P&gt;We were able to use Postman to get our initial access token in step 1 of this post, but you will need to account for that token, and future ones, expiring after about an hour. Here's some Qlik script that you can use to achieve this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// ===================================================================
//  GET NEW TOKEN
// ===================================================================

SUB GetGoogleToken
    LIB CONNECT TO 'Google Refresh Token';

    [Refresh Token Response]:
    SQL SELECT 
        "access_token",
        "expires_in",
        "scope",
        "token_type"
    FROM JSON (wrap on) "root";

    [Refresh Token]:
    LOAD
        Now() as [token_acquired_ts],
        [access_token],
        [expires_in],
        [scope],
        [token_type]
    RESIDENT [Refresh Token Response];
    DROP TABLE [Refresh Token Response];
    
    Store [Refresh Token] into 'lib://DataFiles/google_token.qvd'(QVD);
    Let vToken = peek('access_token', 0, 'Refresh Token');
    Drop Table [Refresh Token];
END SUB


// ===================================================================
//  TOKEN CHECK
// ===================================================================

SUB TokenCheck
    Let vNow = Now();
    Let vQVD_ts = Coalesce(timestamp#( QvdCreateTime('lib://DataFiles/google_token.qvd')  + (60/60/24) - ((60/60/24/60/60)*5) ), 0);
    Let vCompare = timestamp('$(vNow)') &amp;gt; timestamp('$(vQVD_ts)');
    
    IF timestamp(Now()) &amp;gt; timestamp(Coalesce( QvdCreateTime('lib://DataFiles/google_token.qvd')  + (60/60/24) - ((60/60/24/60/60)*5), 0) ) THEN
        Trace #### Graph token expired...getting new token now.;
        Call GetGoogleToken
    ELSE
        Trace #### Graph token still good.;
        
        [Access Token]: LOAD [access_token] FROM 'lib://DataFiles/google_token.qvd'(QVD);
        Let vToken = peek('access_token', 0, 'Access Token');
        Drop Table [Access Token];
    END IF
END SUB&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order for this script to work, you will need to create another REST connection in Qlik, like so:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;URL:&amp;nbsp;&lt;A href="https://oauth2.googleapis.com/token" target="_blank"&gt;https://oauth2.googleapis.com/token&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Method: POST&lt;/LI&gt;
&lt;LI&gt;Request body:&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;client_id=whatever-your-client-id-is.apps.googleusercontent.com&amp;amp;client_secret=whatever-your-client-secret-is&amp;amp;refresh_token=whatever-your-refresh-token-is&amp;amp;grant_type=refresh_token&lt;/PRE&gt;
&lt;UL&gt;
&lt;LI&gt;Query headers:
&lt;UL&gt;
&lt;LI&gt;Content-Type |&amp;nbsp;application/x-www-form-urlencoded&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;Security
&lt;UL&gt;
&lt;LI&gt;&lt;span class="lia-unicode-emoji" title=":ballot_box_with_check:"&gt;☑️&lt;/span&gt; Allow HTTPS only&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should result in a new access token that Qlik can use to continue getting the Google licensing info, at least until the refresh token itself expires (not sure what the default it, that may be set by organization policy).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Notes about the Qlik script&lt;/H2&gt;
&lt;P&gt;That script has been tested and logically works, but my implementation may be a bit tortured or lazy in some ways, just an FYI. It uses &lt;A href="https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptControlStatements/Sub.htm" target="_blank" rel="noopener"&gt;Subroutines&lt;/A&gt; to define reusable procedures called&amp;nbsp;&lt;STRONG&gt;GetGoogleToken&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;TokenCheck&lt;/STRONG&gt; (if you're unfamiliar with subroutines, they're basically like functions you write in Qlik). You can use those subroutines like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;CALL TokenCheck;

LIB CONNECT TO 'Google Licensing 1';

RestConnectorMasterTable:
SQL SELECT 
	"kind" AS "kind_u0",
	"etag",
	"__KEY_root",
	(SELECT 
		"kind",
		"etags",
		"productId",
		"userId",
		"selfLink",
		"skuId",
		"skuName",
		"productName",
		"__FK_items"
	FROM "items" FK "__FK_items")
FROM JSON (wrap on) "root" PK "__KEY_root"

  WITH CONNECTION (
    HTTPHEADER "Authorization" "Bearer $(vToken)"
);

[items]:
LOAD
	[kind],
	[etags],
	[productId],
	[userId],
	[selfLink],
	[skuId],
	[skuName],
	[productName],
	[__FK_items] AS [__KEY_root]
RESIDENT RestConnectorMasterTable
  WHERE NOT IsNull([__FK_items])
;

[root]:
LOAD
	[kind_u0] AS [kind_u0],
	[etag],
	[__KEY_root]
RESIDENT RestConnectorMasterTable
  WHERE NOT IsNull([__KEY_root])
;

DROP TABLE RestConnectorMasterTable;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The script above will:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Call the&amp;nbsp;&lt;STRONG&gt;TokenCheck&lt;/STRONG&gt; subroutine, which will get the token that we have stored to a QVD and check to see if it's expired -- if it&amp;nbsp;&lt;STRONG&gt;is&lt;/STRONG&gt; expired, it calls the&amp;nbsp;GetGoogleToken subroutine to go refresh that token and get a new one, which gets stored back to that same QVD. It will then set that token value to a variable called&amp;nbsp;&lt;STRONG&gt;vToken&lt;/STRONG&gt;. If, however, the token in the QVD is&amp;nbsp;&lt;STRONG&gt;not&lt;/STRONG&gt; expired, it will simply set it to the&amp;nbsp;&lt;STRONG&gt;vToken&amp;nbsp;&lt;/STRONG&gt;variable.&lt;/LI&gt;
&lt;LI&gt;Now that we have our token, we use the&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/cloud-services/Subsystems/REST_Connector_help/Content/Connectors_REST/Load-REST-data/Load-data.htm#anchor-5" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;WITH CONNECTION&lt;/STRONG&gt; command&lt;/A&gt; to dynamically update our&amp;nbsp;&lt;STRONG&gt;Authorization&lt;/STRONG&gt; header with our unexpired token using the&amp;nbsp;&lt;STRONG&gt;vToken&lt;/STRONG&gt; variable.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H2&gt;Further enhancements to this process&lt;/H2&gt;
&lt;P&gt;You could take this all a step further by looping through the &lt;A href="https://developers.google.com/admin-sdk/licensing/v1/how-tos/products" target="_blank" rel="noopener"&gt;list of Google products&lt;/A&gt; to get the license use for all of your relevant products.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 22:16:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Integration-Extension-APIs/Integration-of-Google-API-into-Qlik-Sense-data-connection/m-p/2071590#M18558</guid>
      <dc:creator>AustinSpivey</dc:creator>
      <dc:date>2023-05-15T22:16:33Z</dc:date>
    </item>
  </channel>
</rss>

