Skip to content

Conversation

@Matin-B
Copy link

@Matin-B Matin-B commented May 9, 2023

This pull request fixes an issue where a 403 error was returned when trying to use the WooCommerce API in Python. The issue was caused by the lack of a User-Agent header in the API requests.

To fix the issue, a User-Agent header has been added to the API requests, with the value "sample.org" (or anything else).

Changes made:

  • Added a User-Agent header to the API requests with the value "sample.org".

Example usage:

from woocommerce import API

wcapi = API(
    url="http://example.com",
    consumer_key="consumer_key",
    consumer_secret="consumer_secret",
    version="v2",
    user_agent="sample.org", # Your sample user agent
)

@NeosinneR
Copy link
Member

Hi @Matin-B, user_agent has a default value of WooCommerce-Python-REST-API/3.0.0 so when you get 403 response, it might be, that your server is blocking the default user agent. However, for examples in docs, it's not required to set user_agent.

@NeosinneR NeosinneR closed this Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants