basic_shopify_api/utils.py
def hmac_verify(source: str, secret: str, params: dict, hmac_header: str = None) -> bool:
    """
    Verify if the HMAC is correct.
    """

    if source == "standard":
        # Standard 0Auth/URL method
        hmac_param = params["hmac"].encode(e)
        params.pop("hmac", None)
        kwargs = {
            "data": params,
            "build_query": True,
            "build_query_with_join": True,
        }
    elif source == "proxy":
        # Proxy app request method
        hmac_param = params["signature"].encode(e)
        params.pop("signature", None)
        kwargs = {
            "data": params,
            "build_query": True,
            "build_query_with_join": False,
        }
    elif source == "webhook":
        # Webhook data method
        hmac_param = hmac_header.encode(e)
        kwargs = {
            "data": params.encode(e),
            "raw": True,
            "encode": True,
        }

    # Create the HMAC and compare to what was supplied
    hmac_local = create_hmac(**kwargs, secret=secret)
    return hmac.compare_digest(hmac_local, hmac_param)

    Verify if the HMAC is correct.
    
Verify if the HMAC is correct.
Verify if the HMAC is correct .
def hmac_verify(source: str, secret: str, params: dict, hmac_header: str = None) -> bool:
    if source == "standard":
        hmac_param = params["hmac"].encode(e)
        params.pop("hmac", None)
        kwargs = {
            "data": params,
            "build_query": True,
            "build_query_with_join": True,
        }
    elif source == "proxy":
        hmac_param = params["signature"].encode(e)
        params.pop("signature", None)
        kwargs = {
            "data": params,
            "build_query": True,
            "build_query_with_join": False,
        }
    elif source == "webhook":
        hmac_param = hmac_header.encode(e)
        kwargs = {
            "data": params.encode(e),
            "raw": True,
            "encode": True,
        }
    hmac_local = create_hmac(**kwargs, secret=secret)
    return hmac.compare_digest(hmac_local, hmac_param)
def hmac_verify ( source : str , secret : str , params : dict , hmac_header : str = None ) -> bool : if source == "standard" : hmac_param = params [ "hmac" ] . encode ( e ) params . pop ( "hmac" , None ) kwargs = { "data" : params , "build_query" : True , "build_query_with_join" : True , } elif source == "proxy" : hmac_param = params [ "signature" ] . encode ( e ) params . pop ( "signature" , None ) kwargs = { "data" : params , "build_query" : True , "build_query_with_join" : False , } elif source == "webhook" : hmac_param = hmac_header . encode ( e ) kwargs = { "data" : params . encode ( e ) , "raw" : True , "encode" : True , } hmac_local = create_hmac ( ** kwargs , secret = secret ) return hmac . compare_digest ( hmac_local , hmac_param )
Verify if the HMAC is correct.
Verify if the HMAC is correct .
"""
    Verify if the HMAC is correct.
    """ # Standard 0Auth/URL method # Proxy app request method # Webhook data method # Create the HMAC and compare to what was supplied
source
str
secret
str
params
dict
hmac_header
str