You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: support/entra/entra-id/users-groups-entra-apis/python-scripts-microsoft-graph-requests-detected-as-web-crawler.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
---
2
-
title: Python Scripts Making Microsoft Graph Requests are Detected as Web Crawlers
3
-
description: Provides solutions to an issue where Python Scripts might be detected as web-crawlers when making Microsoft Graph requests.
2
+
title: Python Scripts Making Microsoft Graph Requests Are Detected as Web Crawlers
3
+
description: Provides solutions to an issue where Python Scripts might be detected as webcrawlers when making Microsoft Graph requests.
4
4
ms.date: 04/21/2025
5
5
ms.service: entra-id
6
6
ms.custom: sap:Problem with using the Graph SDK - libraries
7
7
ms.reviewer: daga, v-weizhu
8
8
---
9
9
# Python scripts making Microsoft Graph requests are detected as web crawlers
10
10
11
-
This article provides solutions to an issue where Python scripts might be detected as web-crawlers when making Microsoft Graph requests.
11
+
This article provides solutions to an issue where Python scripts might be detected as webcrawlers when making Microsoft Graph requests.
12
12
13
13
## Symptoms
14
14
15
-
A Python script that makes a Microsoft Graph request might sometimes be detected by the gateway as web crawlers. If Python scripts use a pool manager, when you block the request, the following error message is returned:
15
+
A Python script that makes a Microsoft Graph request might sometimes be detected by the gateway as web crawlers. If Python scripts use a pool manager, the following error message is returned when you block the request:
The issue occurs because some Python scripts might not structure their requests in a way that conforms to expected patterns. As a result, the gateway mistakenly identifies the requests as coming from a web-crawler.
27
+
The issue occurs because some Python scripts might not structure their requests in a way that conforms to the expected patterns. As a result, the gateway mistakenly identifies the requests as coming from a webcrawler.
28
28
29
29
## Solution
30
30
31
31
To resolve this issue, use the [Microsoft Graph SDK for Python](https://github.com/microsoftgraph/msgraph-sdk-python-core). If you don't want to use it, structure your requests similarly to how the SDK handles them by using Python's Session object to send requests.
32
32
33
-
Here is an example of how you can structure your requests manually:
33
+
Here's an example of how you can structure your requests manually:
34
34
35
35
```python
36
36
from requests import Request, Session
@@ -46,7 +46,7 @@ def example_request(url):
46
46
> [!NOTE]
47
47
> - The `User-Agent` string in the HTTP request header should be unique to your application or script, differentiating it from generic traffic.
48
48
> - Including additional headers such as `Accept: application/json` can help clarify the intent of your request.
49
-
> - Incorrectly identifying as crawler traffic might result in throttling or other automated mitigations by Microsoft's backend systems. Properly identifying your client helps avoid these issues.
49
+
> - Incorrectly identified as crawler traffic might result in throttling or other automated mitigations by Microsoft's backend systems. Properly identifying your client helps avoid these issues.
50
50
51
51
If you use a different HTTP client, ensure that similar headers are set appropriately. Refer to your HTTP client's documentation for customizing request headers.
52
52
@@ -55,6 +55,6 @@ If you use a different HTTP client, ensure that similar headers are set appropri
55
55
For more guidance on best practices when using Microsoft Graph, see the following articles:
56
56
57
57
-[Use the Microsoft Graph API](/graph/use-the-api)
58
-
-[Throttling guidance for Microsoft Graph](/graph/throttling)
0 commit comments