Coder Social home page Coder Social logo

pypowerbi's People

Contributors

andymcarter avatar benvdhgss avatar brunompacheco avatar chhantyal avatar cmberryau avatar dudil avatar kondratenko-valeriy avatar moorstech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pypowerbi's Issues

Support for Dataflows

Hi Chris,

Any chance of adding support for Dataflows to the library?

Thanks,

Michael Stone

Get Token request returned http error: 401

adal.adal_error.AdalError: Get Token request returned http error: 401 and server response: {"error":"invalid_client"
,"error_description":"AADSTS70002:
The request body must contain the following parameter: 'client_secret or client_assertion'.

I use code from example https://github.com/cmberryau/pypowerbi .
I change nothing except credentials.
Where I should use "client_secret"?

p.s. Sorry for bad english

ADAL is deprecated

Hi Chris,

While working on my project based on pypowerbi, I noticed ADAL has been deprecated for a while now. So I'm using the new MSAL library instead. One of the main tricky parts I noticed is that when passing the authentication token, that ADAL apparently used snake_case while MSAL uses CamelCase for its dictionary keys, this caused some exceptions being thrown by pypowerbi not finding the expected key (i.e. auth_token v.s. authToken)...

I'm just adding the issue here, to not forget about it. I can create a pull request for initial MSAL support.

One question, though, @cmberryau : should we maintain support in pypowerbi for ADAL, or can we drop support for it completely?

Announcement:
https://github.com/AzureAD/azure-activedirectory-library-for-python

Migration guide:
https://docs.microsoft.com/en-us/azure/active-directory/develop/migrate-python-adal-msal

Dataset refresh?

First off all, this is an awesome project!

Do you have any plans to add refreshing of reports?

Python 2 does not have f string

I tried using this library in python 2 but it fails due to the use of f-strings.
Install was done using pip install pypowerbi

Current workaround is to use future-fstrings package. Apply encoding cookie on top of each file in the package.

Upgrade version and upload to Pypi

Hey Chris, I get a bug that I see is fixed in the github repo, but not pushed to Pypi. Can you please upgrade/upload latest version to Pypi? Thanks!

adal.adal_error.AdalError: Server returned an unknown AccountType: unknown

hi:
I am going to retrieve data from a report like:

https://app.powerbi.com/groups/me/apps/d9690d83-440d-48ec-ab79-69814b1fed25/reports/2199edae-e0d7-4761-8495-f84a3c98439c/ReportSectione2e9c77b50eb527393f7?ctid=5d471751-9675-428d-917b-70f44f9630b0

So I tried like your example:

import adal
from pypowerbi.client import PowerBIClient
from pypowerbi.dataset import Column, Table, Dataset

authority_url = 'https://login.windows.net/common'
resource_url = 'https://analysis.windows.net/powerbi/api'
api_url = 'https://api.powerbi.com'

# change these to your credentials
client_id = 'd9690d83-440d-48ec-ab79-69814b1fed25'
username = 'myemailaddress'
password = 'mypassword'

# first you need to authenticate using adal
logger.info('init context...')
context = adal.AuthenticationContext(authority=authority_url,
                                     validate_authority=True,
                                     api_version=None)
logger.info('init context done')

logger.info('acquire token...')
token = context.acquire_token_with_username_password(resource=resource_url,
                                                     client_id=client_id,
                                                     username=username,
                                                     password=password)
logger.info('got token: {}'.format(token))

# create your powerbi api client
logger.info('create client ...')
client = PowerBIClient(api_url, token)
logger.info('create client done.')

But I got the following error in acquire token:

[root@Server_130 try]# python3 a.py
20-09-04 16:27:43 [ INFO] init context...
20-09-04 16:27:43 [ INFO] init context done
20-09-04 16:27:43 [ INFO] acquire token...
20-09-04 16:27:43 [DEBUG] d874be3e-0eff-439b-a6d6-bf65d28b46fd - Authority:Performing instance discovery: ...
20-09-04 16:27:43 [DEBUG] d874be3e-0eff-439b-a6d6-bf65d28b46fd - Authority:Performing static instance discovery
20-09-04 16:27:43 [DEBUG] d874be3e-0eff-439b-a6d6-bf65d28b46fd - Authority:Authority validated via static instance discovery
20-09-04 16:27:43 [DEBUG] d874be3e-0eff-439b-a6d6-bf65d28b46fd - TokenRequest:Acquiring token with username password.
20-09-04 16:27:43 [DEBUG] d874be3e-0eff-439b-a6d6-bf65d28b46fd - CacheDriver:finding with query keys: {'_clientId': '...', 'userId': '...'}
20-09-04 16:27:43 [DEBUG] d874be3e-0eff-439b-a6d6-bf65d28b46fd - CacheDriver:Looking for potential cache entries: {'_clientId': '...', 'userId': '...'}
20-09-04 16:27:43 [DEBUG] d874be3e-0eff-439b-a6d6-bf65d28b46fd - CacheDriver:Found 0 potential entries.
20-09-04 16:27:43 [DEBUG] d874be3e-0eff-439b-a6d6-bf65d28b46fd - UserRealm:Performing user realm discovery at: ...
20-09-04 16:27:43 [DEBUG] Starting new HTTPS connection (1): login.windows.net:443
20-09-04 16:27:44 [DEBUG] https://login.windows.net:443 "GET /common/UserRealm/fei.ju%40nokia-sbel.com?api-version=1.0 HTTP/1.1" 200 136
20-09-04 16:27:44 [DEBUG] d874be3e-0eff-439b-a6d6-bf65d28b46fd - UserRealm:User Realm Discovery Server returned this correlation_id: d874be3e-0eff-439b-a6d6-bf65d28b46fd
20-09-04 16:27:44 [DEBUG] d874be3e-0eff-439b-a6d6-bf65d28b46fd - UserRealm:Discovery response:
 {"ver":"1.0","account_type":"Unknown","cloud_instance_name":"microsoftonline.com","cloud_audience_urn":"urn:federation:MicrosoftOnline"}
20-09-04 16:27:44 [DEBUG] d874be3e-0eff-439b-a6d6-bf65d28b46fd - UserRealm:UserRealm response:
 AccountType: unknown
 FederationProtocol: None
 FederationMetatdataUrl: None
 FederationActiveAuthUrl: None
20-09-04 16:27:44 [ INFO] d874be3e-0eff-439b-a6d6-bf65d28b46fd - TokenRequest:get_token_func returned with error
Traceback (most recent call last):
  File "a.py", line 54, in <module>
    password=password)
  File "/usr/local/lib/python3.6/site-packages/adal/authentication_context.py", line 164, in acquire_token_with_username_password
    return self._acquire_token(token_func)
  File "/usr/local/lib/python3.6/site-packages/adal/authentication_context.py", line 128, in _acquire_token
    return token_func(self)
  File "/usr/local/lib/python3.6/site-packages/adal/authentication_context.py", line 162, in token_func
    return token_request.get_token_with_username_password(username, password)
  File "/usr/local/lib/python3.6/site-packages/adal/token_request.py", line 286, in get_token_with_username_password
    "Server returned an unknown AccountType: {}".format(self._user_realm.account_type))
adal.adal_error.AdalError: Server returned an unknown AccountType: unknown

End points road map

Hi,

do you have a road map of the end points you are planning to add? Are you aiming to cover all end points?

I was thinking about using the library to create/clone groups/workspace/apps and change their data sources.

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Hi,
when running the example data in the README I am getting an error
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Here is the complete file:


JSONDecodeError Traceback (most recent call last)
in
15
16 # post your dataset!
---> 17 client.datasets.post_dataset(dataset)

~\anaconda3\lib\site-packages\pypowerbi\datasets.py in post_dataset(self, dataset, group_id)
130 # 201 - Created. The request was fulfilled and a new Dataset was created.
131 if response.status_code != 201:
--> 132 raise HTTPError(response, f'Post Datasets request returned http code: {response.json()}')
133
134 return Dataset.from_dict(json.loads(response.text))

~\anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs)
898 # used.
899 pass
--> 900 return complexjson.loads(self.text, **kwargs)
901
902 @Property

~\anaconda3\lib\json_init_.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
355 parse_int is None and parse_float is None and
356 parse_constant is None and object_pairs_hook is None and not kw):
--> 357 return _default_decoder.decode(s)
358 if cls is None:
359 cls = JSONDecoder

~\anaconda3\lib\json\decoder.py in decode(self, s, _w)
335
336 """
--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
338 end = _w(s, end).end()
339 if end != len(s):

~\anaconda3\lib\json\decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Has someone come across this?

Cheers, Andi

Relationship

First I would like to thank you for creating this package, saved me a lot of time. It seems currently relationship is not supported when posting a dataset. Will this feature be added in the future?

Bug in datasets. delete_all_datasets

Hi,
in datasets.delete_all_datasets the function detelete dataset is called with:
self.delete_dataset(group_id, dataset.id)

the definition of this function is
def delete_dataset(self, dataset_id, group_id=None):

So I guess group_id and dataset_id are in the wrong order. It should be self.delete_dataset(dataset.id, group_id, )
or
self.delete_dataset(group_id = group_id, dataset_id = dataset.id)

Best,
Johanna

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.