Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User-Agent Header, v2024.12.0 #5178

Open
1 task
tblnd opened this issue Dec 22, 2024 · 1 comment
Open
1 task

User-Agent Header, v2024.12.0 #5178

tblnd opened this issue Dec 22, 2024 · 1 comment
Labels

Comments

@tblnd
Copy link

tblnd commented Dec 22, 2024

Steps To Reproduce

Using the following:

$ bw --version
2024.12.0

$ python --version
Python 3.12.7

$ pip freeze
click==8.1.7
requests==2.32.3

With the follwoing python code

import requests

headers = {
    "Content-Type": "application/x-www-form-urlencoded"
}
data = {
    "grant_type": "client_credentials",
    "scope": "api.organization",
    "client_id": client_id,
    "client_secret": client_secret
}
response = requests.post(url, headers=headers, data=data)
response.raise_for_status()

Results in (using my click script):

$ bwiam list users
{'User-Agent': 'python-requests/2.32.3', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': '157'}
Error: 400 Client Error: Bad Request for url: https://identity.bitwarden.com/connect/token

Expected Result

HTTP 200

Actual Result

HTTP 400

Screenshots or Videos

No response

Additional Context

It seems the authentication endpoint for the public API is expecting curl as a client (User-Agent HTTP header) for the reuqest to be successful, i.e.

import requests

url = "https://identity.bitwarden.com/connect/token"
headers = {
    "User-Agent": "curl/8.5.0", # <- New line
    "Content-Type": "application/x-www-form-urlencoded"
}
data = {
    "grant_type": "client_credentials",
    "scope": "api.organization",
    "client_id": client_id,
    "client_secret": client_secret
}
response = requests.post(url, headers=headers, data=data)
print(response.request.headers)
response.raise_for_status()
print(response.status_code)

Results in (using the same click script)

$ bwiam list users
{'User-Agent': 'curl/8.5.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': '157'}
200

Not sure if it's a client side issue, but I still want to share this to the team and users if useful to anybody. Otherwise, feel free to close this issue.

If this is a hard requirement, I suggestion updating the official documentation.

Thank you!

Build Version

2024.12.0

Environment

Cloud (bitwarden.com)

Environment Details

No response

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.
@tblnd tblnd added the bug label Dec 22, 2024
@tblnd tblnd changed the title User Agent Bug User-Agent Header, v2024.12.0 Dec 22, 2024
@tblnd
Copy link
Author

tblnd commented Dec 22, 2024

I can also confirm that I was not experiencing this behaviour prior to this performance degradation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant