March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I published below report in powerbi server by updating latest SessionId & BaseURL based on Client's interaction from webpage.
Solved! Go to Solution.
Hi, @ViralGajjar2904
Here is a sample API call to generate an embed token:
import requests
import json
def generate_embed_token(username, report_id, dataset_id, workspace_id):
url = "https://api.powerbi.com/v1.0/myorg/reports/{report_id}/GenerateToken"
payload = json.dumps({
"accessLevel": "View",
"identities": [
{
"username": username,
"roles": ["Viewer"],
"datasets": [dataset_id]
}
]
})
headers = {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
}
response = requests.request("POST", url.format(report_id=report_id), headers=headers, data=payload)
if response.status_code == 200:
return response.json()['token']
else:
raise Exception(f"Error generating embed token: {response.text}")
# Example usage:
embed_token = generate_embed_token("user@example.com", "report_id", "dataset_id", "workspace_id")
Ensure that your embedded report uses the token generated for the specific user session. This can be done in your client-side code where the Power BI report is embedded:
var embedToken = 'USER_SPECIFIC_EMBED_TOKEN';
var reportId = 'YOUR_REPORT_ID';
var groupId = 'YOUR_GROUP_ID';
var embedUrl = `https://app.powerbi.com/reportEmbed?reportId=${reportId}&groupId=${groupId}`;
var models = window['powerbi-client'].models;
var embedConfig = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: embedToken,
embedUrl: embedUrl,
id: reportId,
permissions: models.Permissions.All,
settings: {
filterPaneEnabled: false,
navContentPaneEnabled: true
}
};
// Embed the report and display it within the div container.
var reportContainer = document.getElementById('reportContainer');
var report = powerbi.embed(reportContainer, embedConfig);
Use different browser sessions or incognito windows to simulate multiple users accessing the report. Ensure that each session generates and uses a unique embed token.
If this post helps, then please consider Accept it as the solution and kudos to this post to help the other members find it more quickly
Hi, @ViralGajjar2904
The main reason for this problem is that power BI caches parameters and provides the latest values. When you open two websites, the two refresh operations are very close and there is a progress bar, which will cause the report to pick up parameters from the last trigger.
You can consider: generating a new token for each session to ensure that the data is isolated.
If this post helps, then please consider Accept it as the solution and kudos to this post to help the other members find it more quickly
Hi @hackcrr
should I have to generate unique embed token for user wise?
I already configured code for generate embed token, but I do not have multi users for testing purpose.
I am aceessing reports form both websites (n20.netzoom.com & 20.netzoom.com) via Single user, so it might be cretae above problem? I am not sure...!
Could you please suggets how to use embed token once generated.
Hi, @ViralGajjar2904
Here is a sample API call to generate an embed token:
import requests
import json
def generate_embed_token(username, report_id, dataset_id, workspace_id):
url = "https://api.powerbi.com/v1.0/myorg/reports/{report_id}/GenerateToken"
payload = json.dumps({
"accessLevel": "View",
"identities": [
{
"username": username,
"roles": ["Viewer"],
"datasets": [dataset_id]
}
]
})
headers = {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
}
response = requests.request("POST", url.format(report_id=report_id), headers=headers, data=payload)
if response.status_code == 200:
return response.json()['token']
else:
raise Exception(f"Error generating embed token: {response.text}")
# Example usage:
embed_token = generate_embed_token("user@example.com", "report_id", "dataset_id", "workspace_id")
Ensure that your embedded report uses the token generated for the specific user session. This can be done in your client-side code where the Power BI report is embedded:
var embedToken = 'USER_SPECIFIC_EMBED_TOKEN';
var reportId = 'YOUR_REPORT_ID';
var groupId = 'YOUR_GROUP_ID';
var embedUrl = `https://app.powerbi.com/reportEmbed?reportId=${reportId}&groupId=${groupId}`;
var models = window['powerbi-client'].models;
var embedConfig = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: embedToken,
embedUrl: embedUrl,
id: reportId,
permissions: models.Permissions.All,
settings: {
filterPaneEnabled: false,
navContentPaneEnabled: true
}
};
// Embed the report and display it within the div container.
var reportContainer = document.getElementById('reportContainer');
var report = powerbi.embed(reportContainer, embedConfig);
Use different browser sessions or incognito windows to simulate multiple users accessing the report. Ensure that each session generates and uses a unique embed token.
If this post helps, then please consider Accept it as the solution and kudos to this post to help the other members find it more quickly
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |
User | Count |
---|---|
4 | |
4 | |
4 | |
3 | |
3 |