MicrosoftEdge-Extensions icon indicating copy to clipboard operation
MicrosoftEdge-Extensions copied to clipboard

502 Server Error when uploading extension to store

Open dbeilin opened this issue 1 year ago • 2 comments

I'm trying to upload my extension to the Edge store by I get a 502 error. This is my script:

import os
import logging
import requests
from dotenv import load_dotenv

load_dotenv()

logging.basicConfig(
    format="%(asctime)s - %(levelname)s: %(message)s",
    datefmt="%Y/%m/%d %H:%M:%S",
    level=logging.INFO,
)

def fetch_access_token(client_id, client_secret, access_token_url):
    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    data = {
        "client_id": client_id,
        "client_secret": client_secret,
        "grant_type": "client_credentials",
        "scope": "https://api.addons.microsoftedge.microsoft.com/.default",
    }

    response = requests.post(access_token_url, headers=headers, data=data, timeout=20)
    response.raise_for_status()
    token_data = response.json()

    return token_data["access_token"]

def upload_extension(token, api_endpoint, product_id, package_path):
    url = f"{api_endpoint}/v1/products/{product_id}/submissions/draft/package"
    headers = {
        "Authorization": f"Bearer {token}",
        "Content-Type": "application/zip",
    }

    with open(package_path, "rb") as package_file:
        data = package_file.read()
        response = requests.post(url, headers=headers, data=data, timeout=120)
        logging.info("response: %s", response)
    response.raise_for_status()

    operation_id = response.headers.get("Location")
    logging.info(
        "Package uploaded successfully with the operation ID: %s", operation_id
    )


if __name__ == "__main__":
    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"

    access_token = fetch_access_token(edge_client_id, edge_client_secret, edge_access_token_url)
    upload_extension(access_token, edge_api_endpoint, edge_product_id, "extension/ext.zip")

This exact script worked a few weeks ago when I last tried it, it worked for a long time but all of the sudden I started getting server errors. I waited over 24 hours thinking it was a temporary issue, but now it seems like my extension is "blocked".

What could be the issue? I tried:

  • Renewing my secret
  • Reuploading my extension manually

Generating the access token works, it's just the upload itself which is failing:

❯ python extension/main.py
2024/05/21 16:16:42 - INFO: response: <Response [502]>
Traceback (most recent call last):
  File "/Users/beilin/orangutan/extension/main.py", line 56, in <module>
    upload_extension(access_token, edge_api_endpoint, edge_product_id, "extension/ext.zip")
  File "/Users/beilin/orangutan/extension/main.py", line 40, in upload_extension
    response.raise_for_status()
  File "/Users/beilin/.pyenv/versions/3.12.1/envs/playground/lib/python3.12/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 502 Server Error: Bad Gateway for url: https://api.addons.microsoftedge.microsoft.com/v1/products/my-extension-id/submissions/draft/package

If you fill out the env vars in the main function, you should be able to run this script as well. Please assist.

dbeilin avatar May 21 '24 13:05 dbeilin

Ah, I've been getting something similar. See https://github.com/microsoft/MicrosoftEdge-Extensions/discussions/154

danielhjacobs avatar May 22 '24 17:05 danielhjacobs

Same issue on my end, still seeing 503/502 errors, it's been 3 days

MaximeHeckel avatar May 23 '24 18:05 MaximeHeckel

Should be fixed now.

wsxarcher avatar May 27 '24 14:05 wsxarcher

Hi Everyone,

I'm Pritham Kasi from Edge Extensions team!

If you're still facing the issue, please reach out to us @ [email protected] with the problem you're facing along with your Seller ID and extension details and we will try to help as soon as possible.

prithamkasiMSFT avatar May 30 '24 04:05 prithamkasiMSFT