Skip to content

Commit 93bdc1c

Browse files
authored
AB#4682: Convert blog post to article
1 parent 8eefff1 commit 93bdc1c

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

support/entra/entra-id/toc.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@
289289
href: users-groups-entra-apis/identity-of-calling-application-not-established.md
290290
- name: Add an owner to an application
291291
href: users-groups-entra-apis/add-owner-for-application-microsoft-graph.md
292-
292+
- name: Problem with using the Graph SDK - libraries
293+
items:
294+
- name: Python scripts making requests are detected as web crawlers
295+
href: users-groups-entra-apis/python-scripts-microsoft-graph-requests-detected-as-web-crawler.md
293296
- name: Microsoft Entra User Provisioning and Synchronization
294297
items:
295298
- name: User Sign-in or password Problems
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.
4+
ms.date: 04/10/2025
5+
ms.service: entra-id
6+
ms.custom: sap:Problem with using the Graph SDK - libraries
7+
ms.reviewer: daga, v-weizhu
8+
---
9+
# Python scripts making Microsoft Graph requests are detected as web crawlers
10+
11+
This article provides solutions to an issue where Python Scripts might be detected as web-crawlers when making Microsoft Graph requests.
12+
13+
## Symptoms
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:
16+
17+
```output
18+
{'error': {'code': 'UnknownError', 'message': '\r\n403 Forbidden\r\n\r\n
19+
20+
403 Forbidden
21+
22+
\r\n
23+
24+
Microsoft-Azure-Application-Gateway/v2
25+
26+
\r\n\r\n\r\n', 'innerError': {'date': '{UTC Date/Time}', 'request-id': '{guid}', 'client-request-id': '{guid}'}}}
27+
```
28+
29+
## Cause
30+
31+
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.
32+
33+
## Solution
34+
35+
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.
36+
37+
Here is an example of how you can structure your requests manually:
38+
39+
```python
40+
from requests import Request, Session
41+
42+
def example\_request(url):
43+
http = Session()
44+
req = Request('GET', url, headers=h)
45+
prepped = req.prepare()
46+
resp = http.send(prepped)
47+
return resp.json()
48+
```
49+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]

0 commit comments

Comments
 (0)