<?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: Need help API with refresh token in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Need-help-API-with-refresh-token/m-p/4701495#M61311</link>
    <description>&lt;P&gt;I wrote this script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    #"HR-On employees" = let
    // Parametre
    client_id = "xxx",
    client_secret = "yyy",
    api_url = "url",
    token_url = "token",

    // Obtain Authorization Credentials
    ObtainAuthorizationCredentials = Json.Document(
        Web.Contents(token_url,
            [
                Content = Text.ToBinary("grant_type=client_credentials&amp;amp;client_id=" &amp;amp; client_id &amp;amp; "&amp;amp;client_secret=" &amp;amp; client_secret),
                Headers = [#"Content-Type" = "application/x-www-form-urlencoded"]
            ]
        )
    ),

    refresh_token = ObtainAuthorizationCredentials[refresh_token],

    access_token = ObtainAuthorizationCredentials[access_token],

    // Brug token til at hente data
    Kilde = Json.Document(
        Web.Contents(
            api_url,
            [
                Headers = [Authorization = "Bearer " &amp;amp; access_token]
            ]
        )
    ),
    items = Kilde[items]
in
    Kilde,
    items = #"HR-On employees"[items],
    #"Konverteret til tabel" = Table.FromList(items, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Udvidet Column1" = Table.ExpandRecordColumn(#"Konverteret til tabel", "Column1", {"id", "companyAdmin", "leader", "systemUser", "archived", "picture", "systemFields", "customFields", "departments", "roles", "createdAt", "updatedAt", "customId"}, {"id", "companyAdmin", "leader", "systemUser", "archived", "picture", "systemFields", "customFields", "departments", "roles", "createdAt", "updatedAt", "customId"})
in
    #"Udvidet Column1"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And now I get the data.&lt;/P&gt;</description>
    <pubDate>Wed, 21 May 2025 11:10:21 GMT</pubDate>
    <dc:creator>Bokazoit</dc:creator>
    <dc:date>2025-05-21T11:10:21Z</dc:date>
    <item>
      <title>Need help API with refresh token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Need-help-API-with-refresh-token/m-p/4699524#M61286</link>
      <description>&lt;P&gt;Hi I am new to API and tried searching but did not get anything I could understand.&lt;BR /&gt;&lt;BR /&gt;I am trying to get data from a product called HR-On and it needs to retrieve a new token every hour or so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bokazoit_0-1747724794212.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1269586iAD67E313AA4B4244/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bokazoit_0-1747724794212.png" alt="Bokazoit_0-1747724794212.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;further they add this part:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bokazoit_1-1747724844941.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1269587i5024259BC5D9DD56/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bokazoit_1-1747724844941.png" alt="Bokazoit_1-1747724844941.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;if interested link is here:&amp;nbsp;&lt;A href="https://api.hr-on.com/#tag/Authentication" target="_blank"&gt;https://api.hr-on.com/#tag/Authentication&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to do that in power query?&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 07:08:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Need-help-API-with-refresh-token/m-p/4699524#M61286</guid>
      <dc:creator>Bokazoit</dc:creator>
      <dc:date>2025-05-20T07:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need help API with refresh token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Need-help-API-with-refresh-token/m-p/4700419#M61296</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/6923"&gt;@Bokazoit&lt;/a&gt;&amp;nbsp; ,&lt;BR /&gt;Thanks for reaching out to the Microsoft fabric community forum.&lt;BR /&gt;&lt;BR /&gt;The simplest way to connect Power BI to a REST API is by using the Web data connector, which is available in both Power BI Desktop and Power BI Service. This connector allows you to enter a URL that returns data from a REST API and then choose how to transform and load the data into Power BI.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vnmadadimsft_0-1747757830843.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1269749iACF4DAB5967F65DB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vnmadadimsft_0-1747757830843.png" alt="vnmadadimsft_0-1747757830843.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If the REST API requires authentication, you will be prompted to enter your credentials. You can choose from different authentication methods, such as Basic, OAuth2, API Key, or Anonymous. For example, if you are accessing the GitHub API, you can use an OAuth2 token or an API key to authenticate.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Another way to connect Power BI to a REST API is to use the M language, which is the native query language of Power Query. The M language allows you to write custom functions and expressions to access and manipulate data from various sources, including REST APIs. The M language gives you more flexibility and control over the data, but it also requires more coding skills and knowledge of the REST API structure and parameters.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vnmadadimsft_1-1747757830845.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1269748i1B675D371334BA0F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vnmadadimsft_1-1747757830845.png" alt="vnmadadimsft_1-1747757830845.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In Power BI Desktop, go to the Home tab, select "Get Data," and choose "Blank Query." Then open the Advanced Editor and enter the M code needed to connect to the REST API. For instance, you can define a function that accepts a username and returns a list of GitHub repositories for that user.&lt;/P&gt;
&lt;P&gt;let&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Source = (username as text) as table =&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; let&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url = "&lt;A href="https://api.github.com/users/" target="_blank"&gt;https://api.github.com/users/&lt;/A&gt;" &amp;amp; username &amp;amp; "/repos",&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; response = Web.Contents(url),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; json = Json.Document(response),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table = Table.FromRecords(json)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table&lt;BR /&gt;in&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Source&lt;BR /&gt;&lt;BR /&gt;For more information on how to work with REST API please check out: &lt;A href="https://www.mssqltips.com/sqlservertip/6318/read-api-data-with-power-bi-using-power-query/" target="_blank"&gt;Read API Data with Power BI using Power Query&lt;/A&gt;&lt;BR /&gt;For more information on how to handle authentication please check out: &lt;A href="https://learn.microsoft.com/en-us/power-query/handling-authentication" target="_blank"&gt;Handling authentication for Power Query connectors - Power Query | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a&amp;nbsp;KUDOS.&amp;nbsp;Feel free to reach out if you need further assistance.&lt;BR /&gt;Thank you&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 16:18:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Need-help-API-with-refresh-token/m-p/4700419#M61296</guid>
      <dc:creator>v-nmadadi-msft</dc:creator>
      <dc:date>2025-05-20T16:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need help API with refresh token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Need-help-API-with-refresh-token/m-p/4701084#M61300</link>
      <description>&lt;P&gt;This is not how this type of API works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It has a client_id and a client secret that is always the same. But there is also a refresh token. I need help to insert code to handle the refresh token.&lt;/P&gt;</description>
      <pubDate>Wed, 21 May 2025 07:12:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Need-help-API-with-refresh-token/m-p/4701084#M61300</guid>
      <dc:creator>Bokazoit</dc:creator>
      <dc:date>2025-05-21T07:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need help API with refresh token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Need-help-API-with-refresh-token/m-p/4701495#M61311</link>
      <description>&lt;P&gt;I wrote this script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
    #"HR-On employees" = let
    // Parametre
    client_id = "xxx",
    client_secret = "yyy",
    api_url = "url",
    token_url = "token",

    // Obtain Authorization Credentials
    ObtainAuthorizationCredentials = Json.Document(
        Web.Contents(token_url,
            [
                Content = Text.ToBinary("grant_type=client_credentials&amp;amp;client_id=" &amp;amp; client_id &amp;amp; "&amp;amp;client_secret=" &amp;amp; client_secret),
                Headers = [#"Content-Type" = "application/x-www-form-urlencoded"]
            ]
        )
    ),

    refresh_token = ObtainAuthorizationCredentials[refresh_token],

    access_token = ObtainAuthorizationCredentials[access_token],

    // Brug token til at hente data
    Kilde = Json.Document(
        Web.Contents(
            api_url,
            [
                Headers = [Authorization = "Bearer " &amp;amp; access_token]
            ]
        )
    ),
    items = Kilde[items]
in
    Kilde,
    items = #"HR-On employees"[items],
    #"Konverteret til tabel" = Table.FromList(items, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Udvidet Column1" = Table.ExpandRecordColumn(#"Konverteret til tabel", "Column1", {"id", "companyAdmin", "leader", "systemUser", "archived", "picture", "systemFields", "customFields", "departments", "roles", "createdAt", "updatedAt", "customId"}, {"id", "companyAdmin", "leader", "systemUser", "archived", "picture", "systemFields", "customFields", "departments", "roles", "createdAt", "updatedAt", "customId"})
in
    #"Udvidet Column1"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And now I get the data.&lt;/P&gt;</description>
      <pubDate>Wed, 21 May 2025 11:10:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Need-help-API-with-refresh-token/m-p/4701495#M61311</guid>
      <dc:creator>Bokazoit</dc:creator>
      <dc:date>2025-05-21T11:10:21Z</dc:date>
    </item>
  </channel>
</rss>

