GearPlug / microsoftgraph-python

Microsoft Graph API wrapper written in Python
MIT License
96 stars 40 forks source link

'Response' object is not subscriptable and similar #31

Closed biggosh closed 2 years ago

biggosh commented 2 years ago

I got

python3.9/site-packages/microsoftgraph/client.py", line 250, in _request _headers["Authorization"] = "Bearer " + self.token["access_token"] TypeError: 'Response' object is not subscriptable

when I call client.files.drive_root_items() after the authentication phase.

I saw that self.token is an object with attributes data, original, status_code, throttling and data contains the key access_token

So I solved by changing line 250 in client.py to _headers["Authentication"] = "Bearer " + self.token.data["access_token"]

But now in line 215 of client.py value is not a key of data

BG

biggosh commented 2 years ago

I discovered that not all response contains value in data field. i.e. the response for the request to me/drive/root

so I added an if "value" is in response.data: in client.py before line 214.

is it the solution?

I suggest to add a unit test set to the project

ingmferrer commented 2 years ago

This issue should be resolved upgrading to version 1.1.3