Python 3 license checker with cURL error 404 Python 3 license checker with cURL error 404 curl curl

Python 3 license checker with cURL error 404


That happens because in your curl example you pass data as two POST parameters and in the python script you pass them as JSON body. Also, you need to think about error handling.

import jsonfrom urllib import request, parse, errorlicense_key = "yyyyyyyy-yyyyyyyy-yyyyyyyy-yyyyyyyy"user_email = "xxxxx@xxxxx.com"def licenseCheck(license_key, user_email, productID="xyzxy"):        url_ = "https://api.gumroad.com/v2/licenses/verify"    pf_permalink = productID    params = {'product_permalink': pf_permalink, 'license_key': license_key}    data=parse.urlencode(params).encode('ascii')    req = request.Request(url_, data=data)    try:      response = request.urlopen(req)      get_response = json.loads(response.read())    except error.HTTPError as e: get_response = json.loads(e.read())        status = False    if get_response['success'] and get_response['email'].lower() == user_email.lower():      status = True    else:      get_response = "Failed to verify the license."    return status, get_response , license_keyprint(licenseCheck(license_key, user_email))