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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pbimdland
Regular Visitor

Embed Token API Error: Creating embed token with multiple identities is not supported

Hello everyone,

 

I am creating a dashboard in a web application via App Owns Data. I am able to follow this guide and embed my dashboard to the web application: https://docs.microsoft.com/en-us/power-bi/developer/embed-sample-for-customers

 

Also, I am trying to implement Row-Level Security via the REST API as mentioned in this guide: https://docs.microsoft.com/en-us/power-bi/developer/embedded-row-level-security

 

However, the REST API gives me the following error message as the response:

 

 

{'error': {'code': 'InvalidRequest', 'message': 'Creating embed token with multiple identities is not supported'}}

 

 

I am using almost the same payload (see below) as the one mentioned in the guide, and if I comment-out identities, I get the embed token as normal.

 

{
    "accessLevel": "View",
    "identities": [
        {
            "username": "EffectiveIdentity",
            "roles": [ "Role1", "Role2" ],
            "datasets": [ "fe0a1aeb-f6a4-4b27-a2d3-b5df3bb28bdc" ]
        }
    ]
}

 

 

Any ideas why I'm getting this error message? Thanks.

 

2 REPLIES 2
jayvandenbos
Frequent Visitor

Hi,

 

I got the same error and contacted the Microsoft Power BI support team and they helped me out. Turns out there was something wrong with my request.

 

I'm creating an App owns data web application in Python Django and this is what works for me. 

import requests
import json

username = '...'
password = '...'
client_id = '...'
report_id = '...'
group_id = '...'
dataset_id = '...'
settings = {
            "accessLevel": "View",
            "identities": [
                {
                "username": "Andrew Ma",
                "roles": [ "Manager" ],
                "datasets": [ dataset_id ]
                }
            ]
        }

data = {
    'grant_type': 'password',
    'scope': 'openid',
    'resource': r'https://analysis.windows.net/powerbi/api',
    'client_id': client_id,
    'username': username,
    'password': password
}
# Get access token
response = requests.post('https://login.microsoftonline.com/common/oauth2/token', data=data)
print(response.content)
access_token = response.json().get('access_token')

# Get embed token
dest = 'https://api.powerbi.com/v1.0/myorg/groups/' + group_id \
    + '/reports/' + report_id + '/GenerateToken'
embed_url = 'https://app.powerbi.com/reportEmbed?reportId=' \
    + report_id + '&groupId=' + group_id
headers = {'Authorization': 'Bearer ' + access_token, 'Content-Type': 'application/json'}
response = requests.post(dest, json=settings, headers=headers)
print(response.content)
embed_token = response.json().get('token')
print(embed_token)

Turns out I forgot to add the Content-Type: application/json to the request headers. Also, my settings weren't formatted as json in the request.

 

Hope this helps you out.

 

Regards

pbimdland
Regular Visitor

Nobody at Microsoft knows what this error means?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.