<?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 OAUTH2 client credentials token request error 'Bad request' in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/OAUTH2-client-credentials-token-request-error-Bad-request/m-p/2590277#M36846</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm facing issues with the oauth2 token request in Power Query. See the query below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
AccessToken = Json.Document(Web.Contents("xxx", 
    [
        Headers=[Accept="application/json", #"Content-Type"="application/x-www-form-urlencoded"],
        Content=Text.ToBinary(
            "grant_type=client_credentials&amp;amp;
            client_id=xxx&amp;amp;
            client_secret=xxx&amp;amp;
            scope=xxx"
        )
    ]))


in
AccessToken&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm facing the error below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jordy233_0-1655749768960.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/735259iF819761478BD4AD3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jordy233_0-1655749768960.png" alt="jordy233_0-1655749768960.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Postman, I succeeded to get a response with token.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could anyone provide any help?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Jun 2022 18:32:44 GMT</pubDate>
    <dc:creator>jordy233</dc:creator>
    <dc:date>2022-06-20T18:32:44Z</dc:date>
    <item>
      <title>OAUTH2 client credentials token request error 'Bad request'</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/OAUTH2-client-credentials-token-request-error-Bad-request/m-p/2590277#M36846</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm facing issues with the oauth2 token request in Power Query. See the query below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
AccessToken = Json.Document(Web.Contents("xxx", 
    [
        Headers=[Accept="application/json", #"Content-Type"="application/x-www-form-urlencoded"],
        Content=Text.ToBinary(
            "grant_type=client_credentials&amp;amp;
            client_id=xxx&amp;amp;
            client_secret=xxx&amp;amp;
            scope=xxx"
        )
    ]))


in
AccessToken&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm facing the error below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jordy233_0-1655749768960.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/735259iF819761478BD4AD3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jordy233_0-1655749768960.png" alt="jordy233_0-1655749768960.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Postman, I succeeded to get a response with token.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Could anyone provide any help?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 18:32:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/OAUTH2-client-credentials-token-request-error-Bad-request/m-p/2590277#M36846</guid>
      <dc:creator>jordy233</dc:creator>
      <dc:date>2022-06-20T18:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: OAUTH2 client credentials token request error 'Bad request'</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/OAUTH2-client-credentials-token-request-error-Bad-request/m-p/2596849#M36919</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/338771"&gt;@jordy233&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Please review the following links which has the similar problem with yours, hope they can help you resolve the problem.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.powerbi.com/t5/Power-Query/400-Bad-Request-using-Web-Contents-to-connect-to-REST-API-via/td-p/563178" target="_self"&gt;&lt;SPAN&gt;(400) Bad Request using Web.Contents to connect to REST API via Oauth2&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;There is a similar blog providing details about how to connect to REST API via OAuth2 in Power BI, you can following the instructions in this&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://chris.koester.io/index.php/2015/07/16/get-data-from-twitter-api-with-power-query/" target="_self" rel="nofollow noopener noreferrer"&gt;blog&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;to connect to your data source.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="3"&gt;&lt;SPAN&gt;If you still get error, you can use Fiddler to track the process following the guide in this&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://www.youtube.com/watch?v=YHSTskjur8k" target="_self" rel="nofollow noopener noreferrer"&gt;video&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/72412769/powerbi-datasource-error-web-contents-failed-to-get-contents-400-bad-request" target="_self"&gt;PowerBI DataSource.Error: Web.Contents failed to get contents (400): Bad request&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In addition, you can refer the following links to get the token.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.bmc.com/blogs/microsoft-apis-authentication-tokens/" target="_self"&gt;Getting Authentication Access Tokens for Microsoft APIs&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.linkedin.com/pulse/accessing-api-oauth2-using-m-language-power-bi-diogenes-santos" target="_self"&gt;Accessing API with Oauth2 using M language in Power BI&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Best Regards&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2022 07:55:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/OAUTH2-client-credentials-token-request-error-Bad-request/m-p/2596849#M36919</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-06-23T07:55:23Z</dc:date>
    </item>
  </channel>
</rss>

