<?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: Setup Web Credentials for Application Insights by API in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Setup-Web-Credentials-for-Application-Insights-by-API/m-p/2688417#M37795</link>
    <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="385856" data-lia-user-login="megel" class="lia-mention lia-mention-user"&gt;megel&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;You can try to use the following M query code if help with your scenario:&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    secretId = xxxxx,
    authKey = "Basic " &amp;amp; secretId,
    url = "https://api.xxxxx.com/oauth2/token",
    GetJson =
        Web.Contents(
            url,
            [
                Headers = [
                    #"Authorization" = authKey,
                    #"Content-Type" = "application/x-www-form-urlencoded;charset=UTF-8"
                ],
                Content = Text.ToBinary("grant_type=client_credentials")
            ]
        ),
    token = Json.Document(GetJson)[access_token],
    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;&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, 09 Aug 2022 01:48:59 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-08-09T01:48:59Z</dc:date>
    <item>
      <title>Setup Web Credentials for Application Insights by API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Setup-Web-Credentials-for-Application-Insights-by-API/m-p/2685184#M37758</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;I want to setup the Web Credentials for my Dataset by API from a service:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;The Datasource is an Application Insights component. To do this manual, I have to use my organizational account.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;But I want to do this automatically and for this I want to uses this API:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;PATCH&lt;/SPAN&gt;&lt;SPAN&gt; &lt;A href="https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources/{datasourceId" target="_blank" rel="noopener"&gt;https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources/{datasourceId&lt;/A&gt;}&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Authorization&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;Bearer {token}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Content-Type&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;application/json&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"credentialDetails"&lt;/SPAN&gt;&lt;SPAN&gt;: {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"credentialType"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"OAuth2"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"credentials"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"{\"credentialData\":[{\"name\":\"accessToken\", \"value\":\"{access_token}\"}]}"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"encryptedConnection"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"Encrypted"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"encryptionAlgorithm"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"None"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"privacyLevel"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"Organizational"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Here are my questions:&lt;/STRONG&gt;&lt;BR /&gt;1) How do I get the correct &lt;STRONG&gt;access_token&lt;/STRONG&gt; for my account?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;2) Is it possible to use a Service Account?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;3) Which Permissions do I need for an &lt;STRONG&gt;Azure AD AppRegistration&lt;/STRONG&gt;, to get the access_token within a &lt;STRONG&gt;client credential flow&lt;/STRONG&gt;?&lt;BR /&gt;4) Which Scope / Resource do I need&amp;nbsp;&lt;STRONG&gt;client credential flow?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Aug 2022 07:31:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Setup-Web-Credentials-for-Application-Insights-by-API/m-p/2685184#M37758</guid>
      <dc:creator>megel</dc:creator>
      <dc:date>2022-08-09T07:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Setup Web Credentials for Application Insights by API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Setup-Web-Credentials-for-Application-Insights-by-API/m-p/2688417#M37795</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="385856" data-lia-user-login="megel" class="lia-mention lia-mention-user"&gt;megel&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;You can try to use the following M query code if help with your scenario:&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    secretId = xxxxx,
    authKey = "Basic " &amp;amp; secretId,
    url = "https://api.xxxxx.com/oauth2/token",
    GetJson =
        Web.Contents(
            url,
            [
                Headers = [
                    #"Authorization" = authKey,
                    #"Content-Type" = "application/x-www-form-urlencoded;charset=UTF-8"
                ],
                Content = Text.ToBinary("grant_type=client_credentials")
            ]
        ),
    token = Json.Document(GetJson)[access_token],
    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;&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, 09 Aug 2022 01:48:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Setup-Web-Credentials-for-Application-Insights-by-API/m-p/2688417#M37795</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-08-09T01:48:59Z</dc:date>
    </item>
  </channel>
</rss>

