adoptium / adoptium/api.adoptium.net

Python requests banned?

Open
#580 3 comments 2 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
44
Forks
36
Avg merge
5h 27m
Merged PRs (30d)
42

Description

**Describe the bug**
I am building a Python app and part of it interfaces with the Adoptium API. Using the Requests library, which sends user-agent `python-requests/2.31.0` by default, gives a 403 forbidden error. Not sending a user-agent at all also causes a 403 forbidden. Setting the user-agent to something else fixes the issue, but it shouldn't be a necessary workaround, any user-agent should be allowed.

**To Reproduce**
1. `pip install requests`
2. Write a file like this:

```py
import requests
resp = requests.get("https://api.adoptium.net/v3/info/available_releases")
print(resp.request.headers)
print(resp.headers)
print(resp.status_code)
print(resp.text)
```

4. Run it. Observe 403 error (e.g. first screenshot)
5. Change second line of file to be like this:

```py
resp = requests.get("https://api.adoptium.net/v3/info/available_releases", headers={"User-Agent": "Dummy"})
```

6. Run it again. Observe it works. Wow!

**Expected behavior**
It works with the default requests config

**Screenshots**
Doesn't work with the regular header.
CleanShot 2023-05-30 at 17 43 34@2x
Works when you put some random one. Crazy stuff, one http header is the entire difference between failure and success.
CleanShot 2023-05-30 at 17 44 54@2x

**Device (please complete the following information):**
- OS: macOS Ventura 13.3.1
- Browser: N/A
- Version: N/A

**Additional context**
Looks to be an azure misconfiguration. Also this [happened before](https://github.com/adoptium/api.adoptium.net/issues/575) but it wasn't fixed properly.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the request in the issue with the default Python Requests user-agent, then inspect the API's Azure configuration and compare the earlier issue #575. Done means the available-releases endpoint returns successfully without requiring a custom User-Agent header.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.