Home Technical Talk

Gumroad License Checker - Free Script for a Basic License System

sublime tool
Offline / Send Message
Pinned
Fansub sublime tool




Hey all ! :)

Was cleaning up some code on my 2017-2018 codebase and stumbled upon this old piece of work that i did for PolygonFlow's first iteration last year; a basic licensing function that worked with Gumroad license keys.



<code>urllib2


def gumroadLicenseChecker(license_key, user_email, check="true", productID="ItBYu"): <p><br></p> <p> status, get_response = False, ''</p> <p> try:</p> <p><br></p> <p> url_ = "https://api.gumroad.com/v2/licenses/verify"</p> <p><br></p> <p> pf_permalink = productID # Change the productID to your gumroad product ID (ie. gum.co/ItBYu).</p> <p><br></p> <p> params = json.dumps({"product_permalink": pf_permalink, "license_key": license_key, "increment_uses_count": check})</p> <p><br></p> <p> req = urllib2.Request(url_)</p> <p> req.add_header('Content-Type', 'application/json')</p> <p> response = urllib2.urlopen(req, data=params, timeout = 60)</p> <p> get_response = json.loads(response.read())</p> <p><br></p> <p> if get_response['success'] and get_response['purchase']['email'].lower() == user_email.lower():</p> <p> status = True</p> <p> else:</p> <p> get_response = "Failed to verify the license, please make sure you're using the correct email and license."</p> <p><br></p> <p> except Exception as e:</p> <p> status = False</p> <p> get_response = "Failed to verify the license, please make sure you're using the correct email and license."</p> <p> # print get_response</p> <p><br></p> <p> return status, get_response, license_key</p>import json,



This isn't an unbreakable solution by any means and can be removed with even super basic coding knowledge depending on how you implement it. Back when i was using this function i had an update class whenever a new version would be released, and this class constantly changed and checked for different characteristics in my code.
Obviously it was still breakable but required manual edits everytime an update came out.

I used to use a lot of non-legit software/games when i was in Mauritania and the concept of a credit card barely even existed there, but i also believe in my fellow tech artists getting the most out of their work, so if this can be of any help in that effort i'm all for it ! :)
As always if you want to have access to one of my  tools just drop me an email, i've given away hundreds of licenses for free and will never stop doing so ;)



Note 00 - The productID argument corresponds to the product ID of your gumroad product. For instance you can visit Mesh Blend's page with just gum.co/ItBYu. Each gumroad product has it's own ID.


Note 01 - The check argument here is very important, it changes the behavior of "increment_uses_count". Please check the gumroad link shared above for more on that variable.


Note 02 - Before using this function you need to have license keys enabled in your gumroad product options. Then you can start testing it with your own products ;)



Note 03 - The following lines are what the user will generally input, the third one gives you the response after contacting the gumroad license server

, email_)</code></pre><p></p></div><div>status<b> returns true of false depending on the verification results, </b>get_response<b> is just a json structure for the purchase details and </b>license_key<b> is the same license that the user has given to you.</b><br></div><div><br></div><div><br></div><div><b>Note 04 - </b>The output result of get_response is what's really interesting here, because you can do all kinds of stuff like determining when the license was purchased, if it was refunded, the variant, how many times it was used, quantity(which can be used for studios, for instance) and a few other parameters. <br></div><div><br></div><p>More than a license checking tool, this can actually help you improve your tools by having access to this data (which you can already read in your gumroad dashboard anyway). <br></p><p><br></p><p></p><pre class="CodeBlock"><code><p>{'purchase': {'chargebacked': False,</p>
<p>               'created_at': '2018-12-17T21:58:22Z',</p>
<p>               'custom_fields': [],</p>
<p>               'email': 'dudebro@gmail.com',</p>
<p>               'id': 'GRKffuEINot<code>IValidIBiatcht0Q==',
<p>               'product_name': 'Mesh Blend 1.25 Beta',</p>
<p>               'quantity': 1,</p>
<p>               'refunded': False,</p>
<p>               'variants': '(Standard License)'},</p>
<p> 'success': True,</p>
<p> 'uses': 1}</p>license_ = "34337523-60T14COA-ABD6BAC0-42483A68"
<p>email_ = "userEmail@gmail.com"</p>
<p>status, get_response, license_key = gumroadLicenseChecker(<code>license_



Note 05 - For even better (but still breakable) encryption one could simply distribute the compiled pyc python files instead of the default .py files. This again is not something that will make your work 100% secure but it can help in creating more security layers, which is always useful for the first few days of a product release.


Replies

  • TooLzor
    Options
    Offline / Send Message
    TooLzor polycounter lvl 10
    Dude that's a rad idea, I wasn't aware that you could ping Gumroad (always kind of wondered if you could but didn't have time to check into it)
    You could look into the "uses" as well I guess and do what even ADesk does and limit to 2 uses for example (as long as there's a way to deactivate as well)
  • radiancef0rge
    Options
    Offline / Send Message
    radiancef0rge ngon master
  • Fansub
    Options
    Offline / Send Message
    Fansub sublime tool
    @TooLzor yeah and this can also be pushed to be a proper studio licensing system where you can check how many licenses were used, on how many machines, etc...

    The code provided here is still very basic, but I'm sure one can wrap it around a class with more methods for better checking/obfuscation, studio license monitoring, etc... :) 

  • TooLzor
    Options
    Offline / Send Message
    TooLzor polycounter lvl 10
    Well I think I might wrap Photoshop extensions in it cause you can't mess with it without killing to the signing ticket. But it's cool to know you can check against it.

    If I find anything I'll let you know of course 😊
Sign In or Register to comment.