Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
rodrigopizarro
New Member

Using the Power BI Authentication API returns accessToken null

I'm developing a custom visual for Power BI, and I'm trying to use the Authentication API (https://learn.microsoft.com/en-us/power-bi/developer/visuals/authentication-api). I wrote this function:

 

  const authenticate = () => {
    props.host.acquireAADTokenService.acquireAADTokenstatus().then((acquireTokenStatus) => {
      console.log('allowed?', acquireTokenStatus)
      if (acquireTokenStatus === powerbi.PrivilegeStatus.Allowed) {
        props.host.acquireAADTokenService
          .acquireAADToken()
          .then((acquireAADTokenResult: AcquireAADTokenResult) => {
            console.log('access token', acquireAADTokenResult)
            if (acquireAADTokenResult.accessToken) {
              getDatasetInfo(acquireAADTokenResult.accessToken, props.datasetId).then((createdDataset) =>
                setDataset(createdDataset),
              )
            }
          })
      }
    })
  }

 

It logs `allowed? 0`, meaning the privilege is allowed in the project, and then the accessToken is always null. I enabled the option of obtaining Entra ID tokens (https://learn.microsoft.com/en-us/fabric/admin/organizational-visuals#obtain-microsoft-entra-access-...). I also added the privileges to the project, with the url I configured in my Azure application

 

 

{
  "privileges": [
    {
      "name": "WebAccess",
      "essential": true,
      "parameters": ["*"]
    },
    {
      "name": "ExportContent",
      "essential": true
    },
    {
      "name": "AADAuthentication",
      "parameters": ["https://mywebsite.com"]
    }
  ],

 

I also added permissions in the Azure application and I tried adding localhost as a URI redirect.

 

From what I understood this should be working. What's missing?

0 REPLIES 0

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.