<?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: Custom Data Connector: Refreshing JWT Handling in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Refreshing-JWT-Handling/m-p/1951697#M30467</link>
    <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please review the solution in the following threads which has the similar problem with yours, hope they can also help you resolve the problem.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/requests-to-a-JWT-API-token/td-p/1097823" target="_self"&gt;&lt;STRONG&gt;requests to a JWT API token&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;H2 class="message-subject"&gt;&lt;A href="https://community.powerbi.com/t5/Power-Query/Decode-JWT-token-in-custom-connector/m-p/1643221" target="_self"&gt;&lt;STRONG&gt;Decode JWT token in custom connector&lt;/STRONG&gt;&lt;/A&gt;&lt;/H2&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/51023822/power-bi-get-jwt-token-from-auth-api" target="_self"&gt;&lt;STRONG&gt;Power BI - Get JWT Token from Auth &lt;/STRONG&gt;&lt;/A&gt;&lt;A href="https://docs.microsoft.com/en-us/azure/active-directory/develop/developer-glossary#access-token" target="_self"&gt;&lt;STRONG&gt;API&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/azure/active-directory/develop/developer-glossary#access-token" target="_self"&gt;&lt;STRONG&gt;access token&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jul 2021 09:06:55 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-07-12T09:06:55Z</dc:date>
    <item>
      <title>Custom Data Connector: Refreshing JWT Handling</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Refreshing-JWT-Handling/m-p/1943784#M30396</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am currently working on developing a Custom Data Connector which calls a Security API for a refreshable JWT that expires in 30 minutes.&lt;/P&gt;&lt;P&gt;This token is passed to the header of the data API request. The data API is paginated by incrementing the "page" variable in the URL by 1. I achieve this in a loop to return all my results in one table.&lt;/P&gt;&lt;P&gt;The data API request returns an updated JWT token in the response header, but as I understand it there is no way for me to access that using Value.Metadata for security reasons.&lt;/P&gt;&lt;P&gt;I am trying to figure out how I can refresh my JWT or include it in my pagination loop so the token does not expire while making my calls to the data API.&lt;/P&gt;&lt;P&gt;This API does not adhere to OAuth standards.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;section test_help;

[DataSource.Kind="test_help", Publish="test_help.Publish"]
shared test_help.Contents = (optional message as text) =&amp;gt;
            
        //getPages function
        let getPages = (Page as number) as table =&amp;gt;
            //security API url 
            let url = "https://sapif.callminer.net/security/getToken",

                //Authentication credentials passed to body of feapif
                body = "{""Username"": ""fake"", ""Password"": ""fake"", ""ApiKey"": ""fake""}",
                Parsed_JSON = Json.Document(body),
                BuildQueryString = Uri.BuildQueryString(Parsed_JSON),
 
                //endDate Variable to capture current date time in UTC
                endDate = DateTimeZone.LocalNow(),

                //date search GET Request
                Host = "https://feapif.callminer.net/api/v2/export/datesearch",

                //custom date search path with DateTimeZone.ToText for enddate and page parameter for pagination
                //score ID 58 for MS and 55 for WC
                Path = "?startDate=2021-05-01T12%3A00%3A00.000Z&amp;amp;stopDate="&amp;amp;DateTimeZone.ToText((endDate)) &amp;amp; "&amp;amp;page="&amp;amp; Number.ToText(Page) &amp;amp;"&amp;amp;records=50&amp;amp;clientCaptureDate=true&amp;amp;scoreIds=58,55",
                Source =   [
                            //JWT auth token passed to Data API header
                            token = Json.Document(Web.Contents(url,[Headers = [#"Content-Type"="application/json; charset=utf-8"], Content = Text.ToBinary(body) ] )),
                            Source =  Json.Document(Web.Contents(Host,
                            [RelativePath=Path,Headers=[#"Content-Type"="application/json; charset=utf-8", Authorization="JWT " &amp;amp; token]]))
                            ],
                Source1 = Source[Source],

                #"Converted to Table" = Table.FromList(Source1, Splitter.SplitByNothing(), null, null, ExtraValues.Error) , 
                #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"RecordInfo", "Contact", "Attributes", "Measures", "Others", "Sections", "Categories", "Scores", "ScoreComponents"}, {"Column1.RecordInfo", "Column1.Contact", "Column1.Attributes", "Column1.Measures", "Column1.Others", "Column1.Sections", "Column1.Categories", "Column1.Scores", "Column1.ScoreComponents"}),
                #"Expanded Column1.RecordInfo" = Table.ExpandRecordColumn(#"Expanded Column1", "Column1.RecordInfo", {"Id", "RowNumber", "TotalRowCount"}, {"Column1.RecordInfo.Id", "Column1.RecordInfo.RowNumber", "Column1.RecordInfo.TotalRowCount"})

            in #"Expanded Column1.RecordInfo",

                //Pagination loop
   
                //Define function
                Source = try List.Generate( ()=&amp;gt; 
                                //try getPages (initialize page variable at 1), if records returned are not null increment page +1 if null stop. Convert list of records to table. 
                                [Result = try getPages(1) otherwise null, Page = 1], 
                                each [Result] &amp;lt;&amp;gt; null, 
                                each [Result = try getPages([Page]+1) otherwise null, Page = [Page]+1],
                                each [Result]
                                ) 
                         otherwise {"1","null","null"},

                     //try catch block to capture empty lists/records
                    #"Converted to Table" = try Table.FromList(Source, Splitter.SplitByNothing(), 1, null, ExtraValues.Error) otherwise Table.FromList({"1"}, Splitter.SplitByNothing(), 1, null, ExtraValues.Error) ,
                    #"Expanded Column1" = Table.ExpandTableColumn(#"Converted to Table", "Column1", {"Column1.RecordInfo.Id", "Column1.RecordInfo.RowNumber", "Column1.RecordInfo.TotalRowCount", "Column1.Contact", "Column1.Attributes", "Column1.Measures", "Column1.Others", "Column1.Sections", "Column1.Categories", "Column1.Scores", "Column1.ScoreComponents"}, {"Column1.RecordInfo.Id", "Column1.RecordInfo.RowNumber", "Column1.RecordInfo.TotalRowCount", "Column1.Contact", "Column1.Attributes", "Column1.Measures", "Column1.Others", "Column1.Sections", "Column1.Categories", "Column1.Scores", "Column1.ScoreComponents"})
         in #"Expanded Column1";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 18:40:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Refreshing-JWT-Handling/m-p/1943784#M30396</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-07T18:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Data Connector: Refreshing JWT Handling</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Refreshing-JWT-Handling/m-p/1951697#M30467</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please review the solution in the following threads which has the similar problem with yours, hope they can also help you resolve the problem.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Desktop/requests-to-a-JWT-API-token/td-p/1097823" target="_self"&gt;&lt;STRONG&gt;requests to a JWT API token&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;H2 class="message-subject"&gt;&lt;A href="https://community.powerbi.com/t5/Power-Query/Decode-JWT-token-in-custom-connector/m-p/1643221" target="_self"&gt;&lt;STRONG&gt;Decode JWT token in custom connector&lt;/STRONG&gt;&lt;/A&gt;&lt;/H2&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/51023822/power-bi-get-jwt-token-from-auth-api" target="_self"&gt;&lt;STRONG&gt;Power BI - Get JWT Token from Auth &lt;/STRONG&gt;&lt;/A&gt;&lt;A href="https://docs.microsoft.com/en-us/azure/active-directory/develop/developer-glossary#access-token" target="_self"&gt;&lt;STRONG&gt;API&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.microsoft.com/en-us/azure/active-directory/develop/developer-glossary#access-token" target="_self"&gt;&lt;STRONG&gt;access token&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 09:06:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Refreshing-JWT-Handling/m-p/1951697#M30467</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-12T09:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Data Connector: Refreshing JWT Handling</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Refreshing-JWT-Handling/m-p/1952321#M30478</link>
      <description>&lt;P&gt;Thank you for your response. I have already retrieved my access token, I am trying to figure out how to refresh it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 13:10:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Refreshing-JWT-Handling/m-p/1952321#M30478</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-12T13:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Data Connector: Refreshing JWT Handling</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Refreshing-JWT-Handling/m-p/1954120#M30493</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I'm sorry that I'm not familiar with this. I found some threads with similar problem here, hope they can help you.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://powerusers.microsoft.com/t5/Connector-Development/Custom-Connector-Token-Refresh/td-p/194942" target="_self"&gt;&lt;STRONG&gt;Custom Connector Token Refresh?&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;
&lt;DIV class="lia-message-subject"&gt;&lt;A href="https://community.powerbi.com/t5/Power-Query/Refresh-token-api-call/m-p/937553" target="_self"&gt;&lt;STRONG&gt;Refresh token api call&lt;/STRONG&gt;&lt;/A&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;H2 class="message-subject"&gt;&lt;A href="https://identityserver4.readthedocs.io/en/latest/topics/refresh_tokens.html" target="_self"&gt;&lt;STRONG&gt;Refresh Tokens&lt;/STRONG&gt;&lt;/A&gt;&lt;/H2&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 08:41:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Custom-Data-Connector-Refreshing-JWT-Handling/m-p/1954120#M30493</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-13T08:41:29Z</dc:date>
    </item>
  </channel>
</rss>

