title: how to get azure AD access_token for ServicePrincipal for power bi reports
body: <p>I need to get Azure AD Access token from Vanilla Javascript code to use it for Power BI reports. I could get some working samples in .net from <a href="https://github.com/microsoft/PowerBI-Developer-Samples" rel="nofollow noreferrer">https://github.com/microsoft/PowerBI-Developer-Samples</a>. But as the website that am using built on third part wordpress like CMS I can't use it.</p>
  <p>All i need is to get Azure AD access token from vanilla javascript or either some post man request?</p>
  <p>I have below configuration values for my power BI report,</p>
  <p>&quot;AzureAd&quot;: {
  &quot;AuthenticationMode&quot;: &quot;ServicePrincipal&quot;,
  &quot;AuthorityUri&quot;: &quot;https://login.microsoftonline.com/organizations/&quot;,
  &quot;ClientId&quot;: &quot;XXXXXXXXX&quot;,
  &quot;TenantId&quot;: &quot;XXXXXXXXXXX&quot;,
  &quot;Scope&quot;: [ &quot;https://analysis.windows.net/powerbi/api/.default&quot; ],
  &quot;PbiUsername&quot;: &quot;&quot;,
  &quot;PbiPassword&quot;: &quot;&quot;,
  &quot;ClientSecret&quot;: &quot;XXXXXXXXXX&quot;
  },
  &quot;PowerBI&quot;: {
  &quot;WorkspaceId&quot;: &quot;XXXXXXXXXXX&quot;,
  &quot;ReportId&quot;: &quot;XXXXXXXXXXX&quot;
  },</p>
  <p>I have tried few javascript samples from below github repo but they did not work,
  <a href="https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser" rel="nofollow noreferrer">https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser</a>.</p>
  <p>Any idea how to get it?</p>