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

Resource not found when uploading my extension #3091

Closed
dbeilin opened this issue Mar 7, 2024 · 1 comment
Closed

Resource not found when uploading my extension #3091

dbeilin opened this issue Mar 7, 2024 · 1 comment

Comments

@dbeilin
Copy link

dbeilin commented Mar 7, 2024

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:

2024/03/07 15:22:01 - INFO: url: https://api.addons.microsoftedge.microsoft.com/v1/products/7d7aaf64-f935-454b-b912-a05ba24685fa/submissions/draft/package
2024/03/07 15:22:01 - INFO: status code: 202
2024/03/07 15:22:01 - INFO: operation id: 7c9a8bc9-79d3-4a04-bd95-879df7509556
2024/03/07 15:22:02 - INFO: { "statusCode": 404, "message": "Resource not found" }

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.

@captainbrosset
Copy link
Contributor

Thanks for raising this issue. But I would suggest creating this issue again on the https://github.com/microsoft/microsoftEdge-Extensions/ repository instead, for example by using the Discussions tab on that repo.
This repo here is only about the documentation of the API, not its implementation.

Hope that makes sense!

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

No branches or pull requests

2 participants