<?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: Connecting to REST API - Trouble authenticating in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Connecting-to-REST-API-Trouble-authenticating/m-p/1905271#M30027</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/113661"&gt;@kasiaw29&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a test on your access token code, it works well.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/535226iA401787FEEF13310/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I think you meet problem when you use this token to get result in your workspace code. You can try to use Web connector to connect to your Group API and then change the access token to dynamic in Advance Editor.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 697px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/535252i29E3DF8E0C0FE662/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/535254iBA4B77BEBD0E36C3/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/535255i68AE987E1603D1F3/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.png" alt="3.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For more details, you may refer to this video and you can try the way in this video to get access token too.&lt;/P&gt;
&lt;P&gt;Video:&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=N8qYRSqRz84" target="_self"&gt;Call Power BI Rest API with Dynamic Access Token From Power BI Desktop&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Rico Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Jun 2021 05:43:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-06-17T05:43:38Z</dc:date>
    <item>
      <title>Connecting to REST API - Trouble authenticating</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Connecting-to-REST-API-Trouble-authenticating/m-p/1895138#M29905</link>
      <description>&lt;P&gt;Hi community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to connect to some REST API's to get data on my PowerBI Workspaces activity in order to get Usage Metrics but per whole real estate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using a function that gets a refreshable access token, when it's invoked and refreshed it returns a new token.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kasiaw29_0-1623397438263.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/531996i7EA36237C92B1932/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kasiaw29_0-1623397438263.png" alt="kasiaw29_0-1623397438263.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I'm passing it into my Queries for workspaces, datasets and reports&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kasiaw29_2-1623397540363.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/532002i77D08AA8DB5E4738/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kasiaw29_2-1623397540363.png" alt="kasiaw29_2-1623397540363.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I'm getting this when it's asking me to specify how to connect:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kasiaw29_1-1623397490144.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/532000iA879872003F22C7F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kasiaw29_1-1623397490144.png" alt="kasiaw29_1-1623397490144.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So somewhere it is failing on passing the access token through. Has anyone tried to accomplish what I'm trying before? Did you run into the same issue? Can you help a girl out, please?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Kasia&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 07:46:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Connecting-to-REST-API-Trouble-authenticating/m-p/1895138#M29905</guid>
      <dc:creator>kasiaw29</dc:creator>
      <dc:date>2021-06-11T07:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Connecting to REST API - Trouble authenticating</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Connecting-to-REST-API-Trouble-authenticating/m-p/1895942#M29925</link>
      <description>&lt;P&gt;Hi....&lt;BR /&gt;i need to build a&amp;nbsp;get access token function, could you share yours function?&lt;BR /&gt;thank you so much&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 12:49:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Connecting-to-REST-API-Trouble-authenticating/m-p/1895942#M29925</guid>
      <dc:creator>allan_oliveira</dc:creator>
      <dc:date>2021-06-11T12:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Connecting to REST API - Trouble authenticating</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Connecting-to-REST-API-Trouble-authenticating/m-p/1898093#M29952</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/170758"&gt;@allan_oliveira&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sure so what I did is created 3 parameters where I stored my App ID, Tenant ID and App Secret&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kasiaw29_0-1623653314731.png" style="width: 200px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/532956iB84A8D182478A67A/image-size/small?v=v2&amp;amp;px=200" role="button" title="kasiaw29_0-1623653314731.png" alt="kasiaw29_0-1623653314731.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can do that by going to Manage Parameters at the top and create a new to store those details.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I have created Get Access Token function, using this code:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;() =&amp;gt;

let
    body = "client_id=" &amp;amp; #"App ID" 
    &amp;amp; "&amp;amp;scope=https://analysis.windows.net/powerbi/api/.default&amp;amp;client_secret=" &amp;amp; #"App Secret" 
    &amp;amp; "&amp;amp;grant_type=client_credentials",
    Data= Json.Document(Web.Contents("https://login.microsoftonline.com/"&amp;amp; TenantID &amp;amp; "/oauth2/v2.0/token/", 
    [Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),
    access_token = Data[access_token]
in
    access_token&lt;/LI-CODE&gt;&lt;P&gt;As you can see I'm referencing my parameters in the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;To test that this works for you press Invoke and you should get a long string with token passing through. You can refresh it and you'll see each time it returns a fresh token.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is as far as I have it working, my issue is passing it into workspace code...it's having trouble authenticating:&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="kasiaw29_1-1623653580231.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/532966i17C3D256B2D7A35C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kasiaw29_1-1623653580231.png" alt="kasiaw29_1-1623653580231.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 06:53:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Connecting-to-REST-API-Trouble-authenticating/m-p/1898093#M29952</guid>
      <dc:creator>kasiaw29</dc:creator>
      <dc:date>2021-06-14T06:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Connecting to REST API - Trouble authenticating</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Connecting-to-REST-API-Trouble-authenticating/m-p/1905271#M30027</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/113661"&gt;@kasiaw29&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a test on your access token code, it works well.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/535226iA401787FEEF13310/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I think you meet problem when you use this token to get result in your workspace code. You can try to use Web connector to connect to your Group API and then change the access token to dynamic in Advance Editor.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 697px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/535252i29E3DF8E0C0FE662/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/535254iBA4B77BEBD0E36C3/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/535255i68AE987E1603D1F3/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.png" alt="3.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;For more details, you may refer to this video and you can try the way in this video to get access token too.&lt;/P&gt;
&lt;P&gt;Video:&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=N8qYRSqRz84" target="_self"&gt;Call Power BI Rest API with Dynamic Access Token From Power BI Desktop&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Rico Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;If this post &lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider &lt;EM&gt;&lt;STRONG&gt;Accept it as the solution&lt;/STRONG&gt;&lt;/EM&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 05:43:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Connecting-to-REST-API-Trouble-authenticating/m-p/1905271#M30027</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-06-17T05:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Connecting to REST API - Trouble authenticating</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Connecting-to-REST-API-Trouble-authenticating/m-p/2075828#M31748</link>
      <description>&lt;P&gt;Hi just getting back to this. It's exactly what I have in my query for workspaces, still doesn't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kasiaw29_0-1631635322761.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/593450i57E568CBBCD6FF0E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="kasiaw29_0-1631635322761.png" alt="kasiaw29_0-1631635322761.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 16:02:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Connecting-to-REST-API-Trouble-authenticating/m-p/2075828#M31748</guid>
      <dc:creator>kasiaw29</dc:creator>
      <dc:date>2021-09-14T16:02:41Z</dc:date>
    </item>
  </channel>
</rss>

