<?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: Replacing / Renewign API Token in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2499679#M35955</link>
    <description>&lt;P&gt;Hi @Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;H1&gt;&lt;SPAN class=""&gt;Thansk for your reply. I guess the biggest challenge I have right off the bat is I am a complete newbe at all this and really don't fully understand what your code does.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/H1&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;At the moment when setting up I'm dragging the data in via the Get Data &amp;gt; Web&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;The API doens't have an option for /gettoken&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;We ahve the &lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;A target="_blank"&gt;​/api​/auth​/authenticate&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; option which we inset a username &amp;amp; password to and this returns the token code. I'm then insertign this into the HTTP request header parameters for the advanced Get Data from web.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;so I don't get any Secret ID for example&lt;/SPAN&gt;&lt;/P&gt;&lt;H1&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/H1&gt;</description>
    <pubDate>Sat, 07 May 2022 05:41:43 GMT</pubDate>
    <dc:creator>JohNWMCC</dc:creator>
    <dc:date>2022-05-07T05:41:43Z</dc:date>
    <item>
      <title>Replacing / Renewign API Token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2487171#M35813</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;I'm very new to BI and the whoel connecting API's to it. I ahve managed to connect an API from our supplier and pull in the data to Power Bi by using the Get Data &amp;gt; Web option and so can add the beaerer token&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thats' all worked and I have the data in the system but I have now found out the API token needs to be renewed every 30 days and I have no idea how to do this automatically. I have manged to generate a new token but can't see where I can go to manually update this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my main questions:&lt;/P&gt;&lt;P&gt;1. How the heck do I update the berarer token&lt;/P&gt;&lt;P&gt;2. is ther e away to automate getting the updated token every 30 days? They do have a Post option for authentication and a Get option but no idea how to use those so keen for some pointers for readign material&lt;/P&gt;</description>
      <pubDate>Sun, 01 May 2022 05:08:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2487171#M35813</guid>
      <dc:creator>JohNWMCC</dc:creator>
      <dc:date>2022-05-01T05:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing / Renewign API Token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2492045#M35888</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/384896"&gt;@JohNWMCC&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;You can add the get token step into the query table and parameterize the get data step with this variable, then this token will be updated every time the data source refresh.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Sample code:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    //get token
    secretId = xxxxx,
    authKey = "Basic " &amp;amp; secretId,
    url = "https://api.xxxxx.com/xxxxx/gettoken",
    GetJson =
        Web.Contents(
            url,
            [
                Headers = [
                    #"Authorization" = authKey,
                    #"Content-Type" = "application/x-www-form-urlencoded;charset=UTF-8"
                ]
            ]
        ),
    token = Json.Document(GetJson)[access_token],
    //get data
    Result =
        Web.Contents(
            "https://xxxxx.xxx.com",
            [
                Headers = [
                    #"Content-Type" = "application/json",
                    Authorization = "Bearer " + token
                ],
                RelativePath = "/xxxxx/xxxxx"
            ]
        )
in
    Result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 08:54:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2492045#M35888</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-31T08:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing / Renewign API Token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2499679#M35955</link>
      <description>&lt;P&gt;Hi @Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;H1&gt;&lt;SPAN class=""&gt;Thansk for your reply. I guess the biggest challenge I have right off the bat is I am a complete newbe at all this and really don't fully understand what your code does.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/H1&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;At the moment when setting up I'm dragging the data in via the Get Data &amp;gt; Web&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;The API doens't have an option for /gettoken&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;We ahve the &lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;A target="_blank"&gt;​/api​/auth​/authenticate&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; option which we inset a username &amp;amp; password to and this returns the token code. I'm then insertign this into the HTTP request header parameters for the advanced Get Data from web.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;so I don't get any Secret ID for example&lt;/SPAN&gt;&lt;/P&gt;&lt;H1&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/H1&gt;</description>
      <pubDate>Sat, 07 May 2022 05:41:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2499679#M35955</guid>
      <dc:creator>JohNWMCC</dc:creator>
      <dc:date>2022-05-07T05:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing / Renewign API Token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2522218#M36168</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/384896"&gt;@JohNWMCC&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;It should be helpful if you share the document of the API usages, we can create the sample code based on them.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;&lt;A href="http://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;How to Get Your Question Answered Quickly&amp;nbsp;&lt;/A&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 06:12:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2522218#M36168</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-18T06:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing / Renewign API Token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2522591#M36173</link>
      <description>&lt;P&gt;Does this help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Authorised requests to the API should use an Authorisation header with the value Bearer &amp;lt;TOKEN&amp;gt;, where &amp;lt;TOKEN&amp;gt; is an access token obtained through the authorisation flow. The &amp;lt;TOKEN&amp;gt; is only valid for the same IP that was originally used to acquire the token&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Auth&lt;BR /&gt;/api/auth/authenticate&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DESCRIPTION&lt;BR /&gt;This endpoint is used to acquire a bearer token authorisation token. URL STRUCTURE&lt;BR /&gt;&lt;A href="https://api.XXXXXX.com/api/auth/authenticate" target="_blank" rel="noopener"&gt;https://api.XXXXXX.com/api/auth/authenticate&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;METHOD: POST&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;EXAMPLE:&lt;BR /&gt;{&lt;BR /&gt;"username": "user",&lt;BR /&gt;"password": "password"&lt;BR /&gt;}&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;PARAMETERS&lt;BR /&gt;username String(min_length=8, required) The username for the user account who has the API access.&lt;BR /&gt;password String(min_length=8, required) The password for the user account who has the API access.&lt;BR /&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;RETURNS&lt;/U&gt;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"token": "eyJhbGciOiJIUzI1NixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxpZT2hnYzJHNE1YYmFuV21KMGt3NWw4bFBUU0p2RzFlSDVTb09iZn.e6I1b-Sp0CMhrt3Ah1cAEDVVJrDzmBbGGCg",&lt;BR /&gt;"message": null,&lt;BR /&gt;"username": "username",&lt;BR /&gt;"lastName": "One",&lt;BR /&gt;"firstName": "User",&lt;BR /&gt;"emailAddress": “email@email.com”,&lt;BR /&gt;"guid": "ABCDEFGH-1234-5678-9012-ABCDEFGHIK"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;token String The authorisation token&lt;BR /&gt;message String Any message returned&lt;BR /&gt;username String The authorised user’s username&lt;BR /&gt;lastName String The authorised user’s last name&lt;BR /&gt;firstName String The authorised user’s first name&lt;BR /&gt;emailAddress String The authorised user’s email address&lt;BR /&gt;guid String The authorised user’s guid&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Errors&lt;/P&gt;&lt;P&gt;Code 400&lt;/P&gt;&lt;P&gt;Description: Bad Request. The respond body is a plaintext message with more information. { "message": "Username or password is incorrect” }&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 08:13:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2522591#M36173</guid>
      <dc:creator>JohNWMCC</dc:creator>
      <dc:date>2022-05-18T08:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Replacing / Renewign API Token</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2549785#M36432</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/384896"&gt;@JohNWMCC&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;It sounds like the auth 'user/pwd' parts are not sent from the header, you can try to use the following code to use the 'content' option to post requests to get the token:&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    accesstoken = "xxxxx",
    rootURL = "https://api.XXXXXX.com",
    body = "{'username': 'user','password':'password'}",
    authPath = "/api/auth/authenticate",
    GetJson =
        Web.Contents(
            rootURL,
            [
                Headers = [
                    Authorization = "Bearer " &amp;amp; accesstoken,
                    #"Content-Type" = "application/json"
                ],
                RelativePath = authPath,
                Content = Text.ToBinary(body)
            ]
        ),
    token = Json.Document(GetJson)[token],
    //next operations
    Result =
        Web.Contents(
            rootURL,
            [
                Headers = [
                    Authorization = "Bearer " &amp;amp; token,
                    #"Content-Type" = "application/json"
                ],
                RelativePath = "/api/xxxx/xxxx"
            ]
        )
in
    Result&lt;/LI-CODE&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 09:11:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Replacing-Renewign-API-Token/m-p/2549785#M36432</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-05-31T09:11:44Z</dc:date>
    </item>
  </channel>
</rss>

