I am trying to retrieve all orders from bigcommerce API from the orders V2 here: https://developer.bigcommerce.com/api-reference/e898c792ecd41-orders-v2 but I am getting 403 error
.
This is what I am doing:
store_hash = os.environ.get("store_harsh")
headers= {
"Accept": "application/json",
"Content-Type": "application/json",
"X-Auth-Token": access_token,
}
url = f"https://api.bigcommerce.com/stores/{store_hash}/v2/orders"
orders = requests.get(url, headers=headers)
This is the full error:
{
"status": 403,
"title": "You don't have a required scope to access the endpoint",
"type": "https://developer.bigcommerce.com/api-docs/getting-started/api-status-codes",
"errors": {}
}
I have tried specifying the scope in the headers but I still get the same error. I deeply appreciate your time
CodePudding user response:
The API is saying your API Key does not have the required permission to access orders, try re-generating a new API Key and re-submitting.
CodePudding user response:
To extend on my previous answer, here is working Python Code (which I see you are using) that I use to interface with bigcommerce.
class BigCommerce:
"""
Adaptor to communicate with bigcommerce to give us access to all functionality we require.
"""
@newrelic.agent.background_task()
def __init__(self, store_hash, client_id, token):
self.store_hash = store_hash
self.client_id = client_id
self.token = token
self.result = None
self.base_url = "https://api.bigcommerce.com/stores/{}/v3/".format(self.store_hash)
self.header = {
"X-Auth-Client": self.client_id,
"X-Auth-Token": self.token,
"Content-Type": "application/json",
"Accept": "application/json",
}
Note I have the client_id
and token
in there. You need both items to authenticate correctly.
The fact I am using v3
endpoint should not matter.
Also - when I call the API this is the code:
request = requests.get(full_path, headers=self.header)