Edge Store API - Resource not found error when uploading extension #139
-
I'm trying to update my dummy Extension using Edge's store API: import os
import requests
import logging
from dotenv import load_dotenv
load_dotenv()
EDGE_PRODUCT_ID = os.getenv("EDGE_PRODUCT_ID")
EDGE_CLIENT_ID = os.getenv("EDGE_CLIENT_ID")
EDGE_CLIENT_SECRET = os.getenv("EDGE_CLIENT_SECRET")
EDGE_ACCESS_TOKEN_URL = os.getenv("EDGE_ACCESS_TOKEN_URL")
EDGE_API_ENDPOINT = "https://api.addons.microsoftedge.microsoft.com"
logging.basicConfig(
format="%(asctime)s - %(levelname)s: %(message)s",
datefmt="%Y/%m/%d %H:%M:%S",
level=logging.INFO,
)
def fetch_access_token():
url = EDGE_ACCESS_TOKEN_URL
headers = {"Content-Type": "application/x-www-form-urlencoded"}
data = {
"client_id": EDGE_CLIENT_ID,
"client_secret": EDGE_CLIENT_SECRET,
"grant_type": "client_credentials",
"scope": "https://api.addons.microsoftedge.microsoft.com/.default",
}
token_data = requests.post(url, headers=headers, data=data).json()
return token_data["access_token"]
def upload_extension(access_token, package_path):
url = f"{EDGE_API_ENDPOINT}/v1/products/{EDGE_PRODUCT_ID}/submissions/draft/package"
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/zip",
}
with open(package_path, "rb") as package_file:
file = package_file.read()
response = requests.post(url, headers=headers, data=file, timeout=20)
operation_id = response.headers.get("Location")
logging.info("url: %s", url)
logging.info("status code: %s", response.status_code)
logging.info("operation id: %s", operation_id)
# Check upload status
check_status_url = f"{EDGE_API_ENDPOINT}/products/{EDGE_PRODUCT_ID}/submissions/draft/package/operations/{operation_id}"
response_status = requests.get(check_status_url, headers=headers)
logging.info(response_status.text)
return response
if __name__ == "__main__":
upload_extension(fetch_access_token(), "confetti-extension.zip") The above script returns:
I double checked all of my details like the Product ID, Client key/secret, and everything seems to be correct, but no matter what, I still get a Resource not found error when I try to upload my ZIP file. I'm following their docs but it seems I'm still doing something wrong. |
Beta Was this translation helpful? Give feedback.
Answered by
AxiomPraxis
Mar 7, 2024
Replies: 1 comment 1 reply
-
Looks like issue is on line 50. note that url on line 36 has "/v1/products" but check_status_url on line 50 only has "/products" without the v1. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dbeilin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like issue is on line 50.
note that url on line 36 has "/v1/products" but check_status_url on line 50 only has "/products" without the v1.