Skip to content

Commit 99659c8

Browse files
dablabaywet
andauthored
Update README.md
Co-authored-by: Vincent Biret <vincentbiret@hotmail.com>
1 parent 6ea5460 commit 99659c8

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

README.md

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -101,36 +101,7 @@ scopes = ['User.Read', 'Mail.Read']
101101
client = GraphServiceClient(credentials=credentials, scopes=scopes)
102102
```
103103

104-
Below is a more advanced way to configure the GraphServiceClient when you're behind a HTTP proxy:
105-
106-
```py
107-
# Example using sync credentials and delegated access.
108-
from azure.identity.aio import ClientSecretCredential
109-
from httpx import AsyncClient, Timeout
110-
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
111-
from msgraph_core import GraphClientFactory
112-
113-
from msgraph import GraphServiceClient, GraphRequestAdapter
114-
115-
proxies = {'http': 'http://proxy:80', 'https': 'https://proxy:80'}
116-
credentials = ClientSecretCredential(
117-
tenant_id='TENANT_ID',
118-
client_id='CLIENT_ID',
119-
client_secret='CLIENT_SECRET',
120-
proxies=proxies,
121-
)
122-
httpx_proxies = {'http://': proxies['http'], 'https://': proxies['https']}
123-
scopes = ['https://graph.microsoft.com/.default']
124-
http_client = GraphClientFactory.create_with_default_middleware(
125-
client=AsyncClient(proxies=httpx_proxies,
126-
timeout=Timeout(timeout=60.0))) # HTTP timeout connection set to 60 seconds
127-
auth_provider = AzureIdentityAuthenticationProvider(credentials=credentials, scopes=scopes)
128-
client = GraphServiceClient(request_adapter=GraphRequestAdapter(auth_provider=auth_provider, client=http_client))
129-
```
130-
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
132-
underneath to make the authentication calls, so the proxies dict is a bit different for the ClientSecretCredential class as
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.
104+
> **Note**: Refer to the [following documentation page](https://learn.microsoft.com/graph/sdks/customize-client?tabs=python#configuring-the-http-proxy-for-the-client) if you need to configure an HTTP proxy.
134105
135106
## 3. Make requests against the service
136107

0 commit comments

Comments
 (0)