Comments (2)
Hi @Cagataydemirkol,
This approach you are using is used for App Owns Data. With this access-token you will be able to generate embed tokens using the PBI Rest APIs. But embed-tokens are not supported currently in powerbi-jupyter.
You could use master-user approach and specify a username(email) and password in the request with grant_type as 'password'. With this access token you should be able to embed any of the reports.
from powerbi-jupyter.
@bapat-atharva our organization will not allow master user. Our only option is Service Principal for authentication. The service principal has member role in powerbi the workspace of report and dataset.
I am trying to download data from PowerBI visuals programmatically by running code in Google Cloud Function.
def get_powerbi_access_token(secrets: dict, scopes: list =None):
from msal import ConfidentialClientApplication
client_id = secrets['client_id']
client_secret = secrets['client_secret']
tenant_id = secrets['tenent_id']
authority_url = f'https://login.microsoftonline.com/{tenant_id}'
app = ConfidentialClientApplication(client_id,client_credential=client_secret,authority=authority_url)
if not scopes:
scopes = ['https://analysis.windows.net/powerbi/api/.default']
return app.acquire_token_for_client(scopes=scopes)
access_token = get_powerbi_access_token(secrets)['access_token']
report = Report(group_id=group_id, report_id=report_id, auth=access_token)
report
It is throwing below error while running in notebook
Exception Traceback (most recent call last)
File /opt/miniconda3/envs/powerbi/lib/python3.9/site-packages/ipywidgets/widgets/widget.py:773, in Widget._handle_msg(self, msg)
771 if 'buffer_paths' in data:
772 _put_buffers(state, data['buffer_paths'], msg['buffers'])
--> 773 self.set_state(state)
775 # Handle a state request.
776 elif method == 'request_state':
File /opt/miniconda3/envs/powerbi/lib/python3.9/site-packages/ipywidgets/widgets/widget.py:655, in Widget.set_state(self, sync_data)
652 if name in self.keys:
653 from_json = self.trait_metadata(name, 'from_json',
654 self._trait_from_json)
--> 655 self.set_trait(name, from_json(sync_data[name], self))
File /opt/miniconda3/envs/powerbi/lib/python3.9/contextlib.py:126, in _GeneratorContextManager.__exit__(self, typ, value, traceback)
124 if typ is None:
125 try:
--> 126 next(self.gen)
127 except StopIteration:
128 return False
File /opt/miniconda3/envs/powerbi/lib/python3.9/site-packages/traitlets/traitlets.py:1498, in HasTraits.hold_trait_notifications(self)
1496 for changes in cache.values():
1497 for change in changes:
-> 1498 self.notify_change(change)
File /opt/miniconda3/envs/powerbi/lib/python3.9/site-packages/ipywidgets/widgets/widget.py:701, in Widget.notify_change(self, change)
698 if name in self.keys and self._should_send_property(name, getattr(self, name)):
699 # Send new state to front-end
700 self.send_state(key=name)
--> 701 super().notify_change(change)
File /opt/miniconda3/envs/powerbi/lib/python3.9/site-packages/traitlets/traitlets.py:1513, in HasTraits.notify_change(self, change)
1511 def notify_change(self, change):
1512 """Notify observers of a change event"""
-> 1513 return self._notify_observers(change)
File /opt/miniconda3/envs/powerbi/lib/python3.9/site-packages/traitlets/traitlets.py:1560, in HasTraits._notify_observers(self, event)
1557 elif isinstance(c, EventHandler) and c.name is not None:
1558 c = getattr(self, c.name)
-> 1560 c(event)
File /opt/miniconda3/envs/powerbi/lib/python3.9/site-packages/powerbiclient/report.py:202, in Report._on_error(self, change)
200 if (change['new'] is not self.INIT_ERROR_DEFAULT_STATE):
201 self._init_error = self.INIT_ERROR_DEFAULT_STATE
--> 202 raise Exception(change['new'])
Exception: LoadReportFailed - Fail to initialize - Could not resolve cluster
Will this approach work to automate data export from powerbi reports to excel using functions on Azure or GCP?
from powerbi-jupyter.
Related Issues (20)
- powerbiclient installation HOT 2
- Unable to move across report tabs in the embedded report HOT 3
- Uncaught DataCloneError: Failed to execute 'postMessage' on 'Window': CustomEvent object could not be cloned. HOT 2
- Dropdown slicer with single select is not working HOT 1
- Exception: Power BI report is not embedded HOT 1
- ImportError: cannot import name 'get_dataset_config' & QuickVisualize from 'powerbiclient'
- Embed a specified report page or even a single visual
- extract visual data from report in python script and not in jupyter notebook widget. HOT 2
- Adding to Conda-Forge HOT 1
- Report does not render in Microsoft Fabric Notebook HOT 1
- AttributeError: 'DataFrame' object has no attribute 'dtype' HOT 1
- Failed to load model class 'QuickVisualizeModel' from module 'powerbi-jupyter-client' HOT 3
- Failed to load model class 'ReportModel' from module 'powerbi-jupyter-client' HOT 1
- Update_filters HOT 4
- Recover the value of a visual HOT 3
- Set Active page call not working HOT 1
- error displaying widget model not found HOT 2
- LoadReportFailed - Fail to initialize - Could not resolve cluster HOT 1
- Authenticacion with msal.ConfidentialClientApplication() HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from powerbi-jupyter.