Authentication Issue for public shopify app

Shopify Partner
1 0 0

I am new to APIs and I am trying to build a public Shopify app with python and Flask. I am using the starting example I found at All of the functions in the file have a decorator of @helpers.verify_web_call or a similar call to the functions in I have added new routes to the The def products_linking(): example I gave below is one of those routes. I can successfully navigate to the routes but without the decorator I'm running into authentication errors. The following is a function that I have added.

@app.route('/products_linking', methods=['GET'])
# @helpers.verify_web_call
def products_linking():
    shop = request.args.get('shop')
    global ACCESS_TOKEN
        url = f'https://{shop}'
        def get_products():
            endpoint = 'products.json'
            r = requests.get(url + endpoint)
            return r.json()
        products = get_products()
        return render_template('products_linking.html', shop=shop, products=products)

As you can see the decorator for verifying web calls is commented out. The app will run like this but when I click on the products_linking route, the terminal prints out the following for the products and shop variable.

{'errors': '[API] Invalid API key or access token (unrecognized login or wrong password)'}

If I attempt to navigate to the products_linking route without the decorator commented out I receive a 400 level response and the following:

hmac None
data b''

Here is the function from the file

def verify_web_call(f):
    def wrapper(*args, **kwargs) -> bool:
        get_args = request.args
        hmac = get_args.get('hmac')
        data = '&'.join([f"{key}={value}" for key, value in get_args.items() if key != 'hmac']).encode('utf-8')
        if not verify_hmac(data, hmac):
            logging.error(f"HMAC could not be verified: \n\thmac {hmac}\n\tdata {data}")

        shop = get_args.get('shop')
        if shop and not is_valid_shop(shop):
            logging.error(f"Shop name received is invalid: \n\tshop {shop}")
        return f(*args, **kwargs)
    return wrapper

Any ideas as to why I'm receiving these responses would be greatly appreciated.

Replies 0 (0)