Skip to content

Commit 631607e

Browse files
Updated example with proxies in README.md
1 parent 390e785 commit 631607e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,20 @@ credentials = ClientSecretCredential(
117117
tenant_id='TENANT_ID',
118118
client_id='CLIENT_ID',
119119
client_secret='CLIENT_SECRET',
120-
proxies=proxies.copy(),
120+
proxies=proxies,
121121
)
122-
proxies['http://'] = proxies.pop('http')
123-
proxies['https://'] = proxies.pop('https')
122+
httpx_proxies = {'http://': proxies['http'], 'https://': proxies['https']}
124123
scopes = ['https://graph.microsoft.com/.default']
125124
http_client = GraphClientFactory.create_with_default_middleware(
126-
client=AsyncClient(proxies=proxies, timeout=Timeout(timeout=60.0))) # HTTP timeout connection set to 60 seconds
125+
client=AsyncClient(proxies=httpx_proxies,
126+
timeout=Timeout(timeout=60.0))) # HTTP timeout connection set to 60 seconds
127127
auth_provider = AzureIdentityAuthenticationProvider(credentials=credentials, scopes=scopes)
128128
client = GraphServiceClient(request_adapter=GraphRequestAdapter(auth_provider=auth_provider, client=http_client))
129129
```
130130

131-
> **Note**: Be careful as the ClientSecretCredential isn't based on the httpx client but is rather using the [requests](https://requests.readthedocs.io/en/latest/) library
131+
> **Note**: Be careful as the ClientSecretCredential isn't based on the [httpx](https://www.python-httpx.org/) client but is rather using the [requests](https://requests.readthedocs.io/en/latest/) library
132132
underneath to make the authentication calls, so the proxies dict is a bit different for the ClientSecretCredential class as
133-
opposed to the httpx AsyncClient. That's why we need to adapt the proxies dict before passing it to the httpx AsyncClient.
133+
opposed to the [httpx](https://www.python-httpx.org/) AsyncClient. That's why we need to adapt the proxies dict before passing it to the [httpx](https://www.python-httpx.org/) AsyncClient.
134134

135135
## 3. Make requests against the service
136136

0 commit comments

Comments
 (0)