Skip to content

Commit d125c27

Browse files
committed
Fix bug on prepared request in graph client
1 parent 34f4992 commit d125c27

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

msgraph/core/_graph_client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ def _graph_url(self, url: str) -> str:
142142

143143
@attach_context
144144
def prepare_request(self, method, url, **kwargs):
145-
req = Request(method, url, **kwargs)
145+
req = Request(
146+
method,
147+
url,
148+
headers=kwargs.get('headers'),
149+
files=kwargs.get('files'),
150+
data=kwargs.get('data'),
151+
json=kwargs.get('json'),
152+
params=kwargs.get('params'),
153+
cookies=kwargs.get('cookies'),
154+
hooks=kwargs.get('hooks'),
155+
)
146156
prepared = Session().prepare_request(req)
147157
return prepared
148158

tests/integration/test_graphclient.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,19 @@ def test_graph_client_picks_options_from_kwargs():
9696
assert response.status_code == 200
9797
assert 'scopes' in response.request.context.middleware_control.keys()
9898
assert response.request.context.middleware_control['scopes'] == scopes
99+
100+
101+
def test_graph_client_allows_passing_optional_kwargs():
102+
"""
103+
Test the graph client allows passing optional kwargs native to the requests library
104+
such as stream, proxy and cert.
105+
"""
106+
credential = _CustomTokenCredential()
107+
scopes = ['User.Read.All']
108+
client = GraphClient(credential=credential)
109+
response = client.get(
110+
'https://proxy.apisandbox.msdn.microsoft.com/svc?url=https://graph.microsoft.com/v1.0/me',
111+
scopes=scopes,
112+
stream=True
113+
)
114+
assert response.status_code == 200

0 commit comments

Comments
 (0)