<?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: Updating OAuth2 Dataset credentials via REST API in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Updating-OAuth2-Dataset-credentials-via-REST-API/m-p/1966492#M30589</link>
    <description>&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/user/viewprofilepage/user-id/86838" target="_blank"&gt;@RicoS&lt;/A&gt;&amp;nbsp;Thanks for your reply.&amp;nbsp;&lt;BR /&gt;I've tried both scenario's (appregistration on SP and the App Registration in Azure AD). Both situations give me an access token. Both access tokens are not accepted by the request I'm sending to the endpoint below.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PATCH https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources/{datasourceId}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Is it possible for you to give it a try yourself? I'd really like to know if this is just me not being able to do this, or that the API is just not working properly.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Jul 2021 18:22:22 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-07-19T18:22:22Z</dc:date>
    <item>
      <title>Updating OAuth2 Dataset credentials via REST API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Updating-OAuth2-Dataset-credentials-via-REST-API/m-p/1962112#M30559</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm running into a issue which is keeping me busy for quite a while now. My goal is to update datasource credentials via PowerShell. I'm now trying it via the REST API Tryout pane from MS. My Powershell Code runs into the exact same issue.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RemyBosman_0-1626437603689.png" style="width: 522px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/554830i5EA6B40C5E4E9947/image-dimensions/522x103?v=v2" width="522" height="103" role="button" title="RemyBosman_0-1626437603689.png" alt="RemyBosman_0-1626437603689.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Scenario:&lt;/STRONG&gt;&lt;BR /&gt;Dataset with two connections: 1 connection to SharePoint, 1 connection to SQL.&lt;BR /&gt;Updating the SQL connections works fine, I'm using the basic request body as described &lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/update-datasource#basic-credentials-example" target="_self"&gt;here&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;Performing the same update on the SharePoint connection with the OAUth2 body fails. Below the body i'm using (obviously with another accesstoken value.&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RemyBosman_0-1626436915230.png" style="width: 668px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/554795iBFA897E3B2FFD64B/image-dimensions/668x147?v=v2" width="668" height="147" role="button" title="RemyBosman_0-1626436915230.png" alt="RemyBosman_0-1626436915230.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;I've tried several methods of retrieving the access token, and I have no idea what way of retrieving it is correct...&lt;BR /&gt;Method 1: Retrieving it via Get-PowerBIAccesToken&amp;nbsp;&lt;BR /&gt;Method 2: Via my registered App in SharePoint with FullControl permission on the corresponding site.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RemyBosman_2-1626437162921.png" style="width: 676px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/554804i3E8C7044BE45AA94/image-dimensions/676x228?v=v2" width="676" height="228" role="button" title="RemyBosman_2-1626437162921.png" alt="RemyBosman_2-1626437162921.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error response is. Any help would be very much appreciated! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RemyBosman_3-1626437264714.png" style="width: 541px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/554807i9D60D53F6E993F83/image-dimensions/541x596?v=v2" width="541" height="596" role="button" title="RemyBosman_3-1626437264714.png" alt="RemyBosman_3-1626437264714.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jul 2021 12:13:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Updating-OAuth2-Dataset-credentials-via-REST-API/m-p/1962112#M30559</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-16T12:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: Updating OAuth2 Dataset credentials via REST API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Updating-OAuth2-Dataset-credentials-via-REST-API/m-p/1965445#M30583</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your request is from this blog&amp;nbsp;&lt;A href="https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/update-datasource#oauth2-credentials-example" target="_self"&gt;OAuth2 credentials example&lt;/A&gt;, it should be correct.&lt;/P&gt;
&lt;P&gt;Rest API:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;PATCH https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources/{datasourceId}&lt;/LI-CODE&gt;
&lt;P&gt;Body:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
  "credentialDetails": {
    "credentialType": "OAuth2",
    "credentials": "{\"credentialData\":[{\"name\":\"accessToken\", \"value\":\"eyJ0....fwtQ\"}]}",
    "encryptedConnection": "Encrypted",
    "encryptionAlgorithm": "None",
    "privacyLevel": "None"
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;Try steps as below to get the correct sharepoint access token.&lt;/P&gt;
&lt;P&gt;For reference:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/63321532/sharepoint-rest-api-how-to-get-access-token" target="_blank"&gt;https://stackoverflow.com/questions/63321532/sharepoint-rest-api-how-to-get-access-token&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://anexinet.com/blog/getting-an-access-token-for-sharepoint-online/" target="_blank"&gt;https://anexinet.com/blog/getting-an-access-token-for-sharepoint-online/&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;</description>
      <pubDate>Mon, 19 Jul 2021 09:49:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Updating-OAuth2-Dataset-credentials-via-REST-API/m-p/1965445#M30583</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-19T09:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: Updating OAuth2 Dataset credentials via REST API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Updating-OAuth2-Dataset-credentials-via-REST-API/m-p/1966492#M30589</link>
      <description>&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/user/viewprofilepage/user-id/86838" target="_blank"&gt;@RicoS&lt;/A&gt;&amp;nbsp;Thanks for your reply.&amp;nbsp;&lt;BR /&gt;I've tried both scenario's (appregistration on SP and the App Registration in Azure AD). Both situations give me an access token. Both access tokens are not accepted by the request I'm sending to the endpoint below.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PATCH https://api.powerbi.com/v1.0/myorg/gateways/{gatewayId}/datasources/{datasourceId}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Is it possible for you to give it a try yourself? I'd really like to know if this is just me not being able to do this, or that the API is just not working properly.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 18:22:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Updating-OAuth2-Dataset-credentials-via-REST-API/m-p/1966492#M30589</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-19T18:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Updating OAuth2 Dataset credentials via REST API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Updating-OAuth2-Dataset-credentials-via-REST-API/m-p/1974926#M30668</link>
      <description>&lt;P&gt;Ok I figured this one out. It seems requesting an access token by 'grant_type' = 'password' does the job, while requesting it via 'grant_type' = 'client_credentials' doesn't.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below the first scenario that works, the response includes a refresh token.&amp;nbsp;&lt;BR /&gt;The second scenario does not work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RemyBosman_0-1627022053297.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/559273i0209D59B18FEE644/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RemyBosman_0-1627022053297.png" alt="RemyBosman_0-1627022053297.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="RemyBosman_2-1627022122594.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/559277i60607C55DF0E265B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RemyBosman_2-1627022122594.png" alt="RemyBosman_2-1627022122594.png" /&gt;&lt;/span&gt;&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="RemyBosman_1-1627022087119.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/559274i63444F2F27387094/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RemyBosman_1-1627022087119.png" alt="RemyBosman_1-1627022087119.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="RemyBosman_3-1627022140388.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/559278i998ABDC63FFE66C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RemyBosman_3-1627022140388.png" alt="RemyBosman_3-1627022140388.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2021 06:37:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Updating-OAuth2-Dataset-credentials-via-REST-API/m-p/1974926#M30668</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-23T06:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Updating OAuth2 Dataset credentials via REST API</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Updating-OAuth2-Dataset-credentials-via-REST-API/m-p/2427886#M35249</link>
      <description>&lt;P&gt;Hi Remy!&lt;/P&gt;&lt;P&gt;I'm having the same problem as you had, and still can'tseem to get a valid token to update the Sharepoint credential...&lt;/P&gt;&lt;P&gt;Could you go through all the steps you took to make it work? (Service Principal configuration and api permissions, any Sharepoint permission granting)... I'm literally running out of options to test this.&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 20:20:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Updating-OAuth2-Dataset-credentials-via-REST-API/m-p/2427886#M35249</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-30T20:20:47Z</dc:date>
    </item>
  </channel>
</rss>

