<?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: Cannot get access token. in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/516487#M15950</link>
    <description>&lt;P&gt;The problem isn't that we're on the client side or the server side, but whether we can support having the user enter credentials.&amp;nbsp; I'm not able to support that in my circumstance (which is a use from an Azure function).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, if you can support the user entering username and password, you may be able to get away with something else.&amp;nbsp; Sorry, I have not tested those scenarios.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In that case, I might start with something like this from Github.&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-js" target="_blank"&gt;https://github.com/AzureAD/azure-activedirectory-library-for-js&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously, if you do have a client-side scenario, security is important -- you cannot have client secrets and passwords floating around in the app.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I couldn't help more, but my usage doesn't seem as if it is like yours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;P&gt;-e&lt;/P&gt;</description>
    <pubDate>Fri, 14 Sep 2018 22:51:43 GMT</pubDate>
    <dc:creator>ericleigh007</dc:creator>
    <dc:date>2018-09-14T22:51:43Z</dc:date>
    <item>
      <title>Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/515391#M15904</link>
      <description>&lt;P&gt;Hello Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble getting a response with the access token. Here is the error I am getting after registering my native app.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;{&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"error": "invalid_grant",&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"error_description": "AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password\r\nTrace ID: cf7bc173-6506-48cb-8729-0258325c9800\r\nCorrelation ID: cf2c4bad-1b0f-40be-bfc3-32a29b1b8551\r\nTimestamp: 2018-09-13 20:42:53Z",&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"error_codes": [&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;70002,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;50126&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;],&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"timestamp": "2018-09-13 20:42:53Z",&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"trace_id": "cf7bc173-6506-48cb-8729-0258325c9800",&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;"correlation_id": "cf2c4bad-1b0f-40be-bfc3-32a29b1b8551"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I get some pointers? I registered the app and made sure I gave the proper permissions..&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 20:50:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/515391#M15904</guid>
      <dc:creator>hsheikhali</dc:creator>
      <dc:date>2018-09-13T20:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/515412#M15905</link>
      <description>&lt;P&gt;most likely need to see your outgoing packet to figure that out, and what code you're using would also help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously the erorr says invalid username or password, but it could be that they're there and correct but not in the correct format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In .NET Core, I'm doing this:&lt;/P&gt;&lt;PRE&gt;            string authBody = $@"
			grant_type = password
			&amp;amp;resource ={WebUtility.UrlEncode(resourceString)}
			&amp;amp;username ={WebUtility.UrlEncode(username)}
			&amp;amp;password ={WebUtility.UrlEncode(password)}
			&amp;amp;client_id ={clientId}
            &amp;amp;client_secret={ WebUtility.UrlEncode(secret)}";&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Sep 2018 21:53:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/515412#M15905</guid>
      <dc:creator>ericleigh007</dc:creator>
      <dc:date>2018-09-13T21:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/515455#M15908</link>
      <description>&lt;P&gt;I plan on getting all the required data to make an API call to the PBI REST Apis for embedded purposes using JavaScript. Right now I am using Postman to get a feel for where to start. Unfortunately I cannot use .NET since I will be unable to run the server side code on our architecture as of right now. I has to be in JS.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 00:17:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/515455#M15908</guid>
      <dc:creator>hsheikhali</dc:creator>
      <dc:date>2018-09-14T00:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/515462#M15909</link>
      <description>&lt;P&gt;Here is what I my post body looks like and the url im hitting.&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="mypostcall.png" style="width: 600px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/119517i220CD232CD5F1C70/image-size/large?v=v2&amp;amp;px=999" role="button" title="mypostcall.png" alt="mypostcall.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 00:22:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/515462#M15909</guid>
      <dc:creator>hsheikhali</dc:creator>
      <dc:date>2018-09-14T00:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/516476#M15948</link>
      <description>&lt;P&gt;I'm using this authority URL&lt;/P&gt;&lt;PRE&gt;https://login.windows.net/{tenantID}/oauth2/token&lt;/PRE&gt;&lt;P&gt;Where {tenantID} is my AAD tenant.&amp;nbsp; I believe that /common/ works as well, but without tenantID some of the context of one's tenant may be lost.&amp;nbsp; Samples I've seen recommend the authority URL format I'm using.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, you may have noticed that my body also includes the client secret.&amp;nbsp; I think without the client secret, the information will be invalid.&amp;nbsp; If you run fiddler, do you see any additional infomation about the error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this info gets you there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-thanks&lt;/P&gt;&lt;P&gt;-e&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 22:06:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/516476#M15948</guid>
      <dc:creator>ericleigh007</dc:creator>
      <dc:date>2018-09-14T22:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/516486#M15949</link>
      <description>&lt;P&gt;This may be a beginner question -- but where do I get the tenant id and client secret? I thought client secret was only for the server side option not the native one?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 22:40:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/516486#M15949</guid>
      <dc:creator>hsheikhali</dc:creator>
      <dc:date>2018-09-14T22:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/516487#M15950</link>
      <description>&lt;P&gt;The problem isn't that we're on the client side or the server side, but whether we can support having the user enter credentials.&amp;nbsp; I'm not able to support that in my circumstance (which is a use from an Azure function).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, if you can support the user entering username and password, you may be able to get away with something else.&amp;nbsp; Sorry, I have not tested those scenarios.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In that case, I might start with something like this from Github.&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;A href="https://github.com/AzureAD/azure-activedirectory-library-for-js" target="_blank"&gt;https://github.com/AzureAD/azure-activedirectory-library-for-js&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obviously, if you do have a client-side scenario, security is important -- you cannot have client secrets and passwords floating around in the app.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry I couldn't help more, but my usage doesn't seem as if it is like yours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;P&gt;-e&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 22:51:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/516487#M15950</guid>
      <dc:creator>ericleigh007</dc:creator>
      <dc:date>2018-09-14T22:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/516488#M15951</link>
      <description>&lt;P&gt;That's fine thanks for the help. I am still experiencing the same error and fiddler doesn't show me anything different. I might move to a node solution but I need to know how I can get an access_token.. Or why I am seeing that error when I've registered my app. Doesn't make sense to me&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 22:54:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/516488#M15951</guid>
      <dc:creator>hsheikhali</dc:creator>
      <dc:date>2018-09-14T22:54:32Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/516674#M15972</link>
      <description>Okay I figured it out!! I wasn’t passing the parameters properly to get the accessToken. Now I got the tolen just fine and realized i dont have the appropriate permission on the app in AAD to get the embedcode&lt;BR /&gt;&lt;BR /&gt;For those curious I used ADAL with node to get the access token</description>
      <pubDate>Sat, 15 Sep 2018 17:52:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/516674#M15972</guid>
      <dc:creator>hsheikhali</dc:creator>
      <dc:date>2018-09-15T17:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/517411#M15980</link>
      <description>&lt;P&gt;just to close the loop, you should share your solution here. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The purpose of these forums assist with people who are having a problem, and they come to see the solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sure sharing a few lines of code will help somebody and they won't have to wait for an answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-thanks&lt;/P&gt;&lt;P&gt;-e&lt;/P&gt;</description>
      <pubDate>Mon, 17 Sep 2018 10:21:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/517411#M15980</guid>
      <dc:creator>ericleigh007</dc:creator>
      <dc:date>2018-09-17T10:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/518804#M16032</link>
      <description>&lt;P&gt;Here is my solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;const axios = require('axios');
const adal = require('adal-node');


const getAccessToken = () =&amp;gt; {
  const config = {
    username: 'Your Username',
    password: 'Your Password',
    clientId: 'Your Client ID',
    resource: 'https://analysis.windows.net/powerbi/api'
  }

  const authority = 'https://login.microsoftonline.com/Your Tenant'; 
  // Tenant can be found in the Azure Portal.
  // When you access Azure AD, it should show your the name of your tenant.
  // Don't have a link but you can figure out where to get this with some googling.


  let context = new adal.AuthenticationContext(authority, true)
  const callback = (err, accessToken) =&amp;gt; {
    if (!err) {
      console.log(accessToken.accessToken); // Returns access token.
      makeApiCall(accessToken.accessToken); --&amp;gt; This is my actual API call.
    } else {
      console.log(err);
    }
  }
  context.acquireTokenWithUsernamePassword(
    config.resource,
    config.username,
    config.password,
    config.clientId,
    callback
  );
}

const makeApiCall = (token) =&amp;gt; {
  const config = {
    headers: {
      'Authorization': "Bearer " + token,
      'Content-Type': 'application/x-www-form-urlencoded',
      'Accept': 'application/json'
    }
  };&lt;BR /&gt;&lt;BR /&gt;   // These options are only used when generating a embedToken.&lt;BR /&gt;
  //{
    //accessLevel:"View",
    //allowSaveAs:"false"
  //}, 

  const url = 'https://api.powerbi.com/v1.0/myorg/groups/5cfa7118-e1eb-4008-afe7-239e5286b9f1/reports/';


  axios.get(url, config)
    .then(response =&amp;gt; {
      let result = response.data;
      console.log(result);
    })
    .catch(err =&amp;gt; {
      console.log(err);
      console.log(err.response.status);
      console.log(err.response.statusText);
    })
}

getAccessToken();&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Sep 2018 12:56:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/518804#M16032</guid>
      <dc:creator>hsheikhali</dc:creator>
      <dc:date>2018-09-18T12:56:56Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/558846#M17501</link>
      <description>&lt;P&gt;i am also facing the similar issue, did you able to figured it out through postman. Please let me know te root cause.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2018 05:07:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/558846#M17501</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-02T05:07:55Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/568361#M17628</link>
      <description>&lt;P&gt;Same issue for me since over half a year now. No solution in sight besides MS C# demo.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 08:34:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/568361#M17628</guid>
      <dc:creator>NEbdf</dc:creator>
      <dc:date>2018-11-19T08:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get access token.</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/2324720#M34282</link>
      <description>&lt;P&gt;I am trying to get access token in React but I am getting bad request&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vidisha_0-1644303283969.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/666399i45C8D6054225ED08/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vidisha_0-1644303283969.png" alt="Vidisha_0-1644303283969.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Feb 2022 06:55:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Cannot-get-access-token/m-p/2324720#M34282</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-02-08T06:55:11Z</dc:date>
    </item>
  </channel>
</rss>

