Showing results for 
Search instead for 
Did you mean: 
Advocate I
Advocate I

How to get Power BI Access Token via Javascript?

I really don't understand how Microsoft and the PowerBI team provided javascript api examples for everything except how to get the access token...  I have been at this for a while trying to figure out how to get access to the api.  I have the client id for an app.  I don't want the users to have to sign in for themselves, I want to use my own microsoft id to get to my tile / dashboard to display on a web page.   Any thoughts?


Note the most relevant articles I found appear to be as follows:


Authenticate a client app (all .net examples) 

Power BI API updates (gives javascript examples for everything but getting access token - which stinks!) 

Integrate a Power BI tile into an app 

Intro to creating a Power BI app

Service to Service Calls Using Client Credentials 


And, of course, I am not the only person who wants to know


So, how the heck to we do this so I can put a chart up on a web page?  


Thank you all.

New Member

Did you have any results?? Im right now with the same problem but trying to push data in some datasets regularly.


Couldn't find any examples nor routines to get a token with JS.

Actually, we did.  This is a few months old, but here is what we found...


I am actually going to sharea complete set of findings related to putting PowerBI in an iFrame...  ADX Studio has the iFrame, but the answer to your question is buried here.


Connecting Power BI to ADX / CRM


  • When the CRM was created (or prior via Office 365), an Azure AD was populated behind the scenes with one or more organizational identities to sign onto CRM.
    • The CRM AD may have been combined with an Office 365 Azure AD (for single sign-on.)
    • The Azure AD should have identities of the organization and it is one of these identities we want to use for Power BI.
      • Preferably, we want a read-only identity for Power BI chart exposure.
      • All the C-Level staff need identities in or federated to this AD for Power BI.
    • Both CRM and ADX expose data via OData feeds.
      • CRM requires a validated identity to get to the OData feeds.
        • CRM is more "granular" with regards to the OData feeds, and as such, may be more difficult to navigate, requiring more knowledge of CRM.
      • ADX does NOT require a validated identity to get to the OData feeds.
        • This may be ideal for Open Gov initiatives.
        • Feeds have to still be created in ADX for each entity. This is not a security hole.


Registering ADX as a Power BI Application


  • oAuth 2.0 requires that the application authenticating, provide a client or web identity.
    • We register a client identity in Azure AD for ADX studio.
      • That identity will be used in javascript along with an anonymous user or "service account" to get access to PowerBI Dashboard Tiles.
      • To register a client identity, there must be access to Azure AD, which may not yet have been enabled.
        • We enable access via an Office 365 management screen that will set up an Azure Subscription with access to Azure AD.
        • We can get to the Office 365 management screen from the top left corner of Power BI, if we are confused.
      • We will need to save a "client id"
      • We will need to provide the application identity privileges to get to Power BI data


Authorizing ADX via oAuth 2.0 for Power BI


  • We use a part of the oAuth 2.0 standard which is supported by Microsoft Azure AD, but is not described in documentation for accessing PowerBI.
    • Lucky, we knew the standard in enough detail to make this work J
    • We use what is known as a "Password Grant" which requires 4 items to get access:
      1. client_id=Client ID from registration in last section.
      2. username=anonymous user's username
      3. password=anonymous user's password
      4. resource=
        • ok, figuring out that resource was friggin hard as hell!!! It is unadvertised by Microsoft, and frankly it could be a risk in the future although the likelihood is low.
  • TODO: figure out best method to secure password, etc. Site Settings are one possible method.
  • We will get an "Access Token" that is sent with every request to Power BI

Discovering Tiles

  • Each "Tile" or chart on the Dashboard has an embed url that can be used in an iFrame.
    • That URL is only currently visible via an API call.
    • TODO: create a non-developer method of finding urls for Tiles

Putting Tiles In an iFrame

  • An iFrame is a part of the window that can contain we page
    • There is javascript that will contact the PowerBI API and display a "Tile" or chart in an iFrame.
    • ADX studio makes the development of javascript and the specification of an iFrame fairly easy.
      • TODO: The challenge is creating a method for non-developers



Bump. Anyone have .js sample of obtaining an authorization code and access token for PowerBI?

Any updates on how to get a hold of the access token???

My understanding is that, unless it is provided as a specific Connector in Power Query (e.g. Facebook, SharePoint Online List maybe), Power BI doesn't currently support the full callback process for user-id/password authentication per oAuth2.  Per, "Power BI cannot read a response returned to a callback URL and if the API you are using requires that “authentication flow” then it can’t be used with Power BI (well, that is not entirely true, but to prevent this blog from being 50 pages long, we will say it can’t). For instance, the LinkedIn API requires this flow so it is not something we can connect to from Power BI easily."


It WILL work for an application-level token per that link showing access via public Twitter Search API.


To help get this service improved, consider voting for an (the best?) oAuth idea at



I am also lost with trying to find the access token.

Hi, how did you pass the username and password for OAuth?  I want to do the same in SharePoint, but I'm confused as how to get at the profile password?  Thanks.

Helpful resources

PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!


Are You Ready?

Test your skills now with the Cloud Skills Challenge.

Top Solution Authors
Top Kudoed Authors