Skip to main content

Python Library for Create and Manage License Key with GitHub Gists

Project description

GistLick

Python Library for Interacting with GitHub Gist API for License Management

GistLick is a powerful and flexible Python library designed to simplify interactions with GitHub's Gist API. It provides a straightforward way to manage your Gists programmatically, including creating, retrieving, updating, and deleting Gists. Furthermore, GistLick extends this functionality to manage custom license keys directly within your Gists, offering tools for license creation, verification, and expiration tracking.

Features

  • Gist Management:
    • List all authenticated user's Gists.
    • Retrieve details and content of a specific Gist.
    • Create new Gists (with optional description and public/private status).
    • Update existing Gists (change name, public status, content, description).
    • Delete Gists by ID.
  • License Key Management:
    • Create unique license keys within a specified Gist, including user, plan, machine ID, and expiration date.
    • Delete specific license keys from a Gist.
    • Delete all expired license keys from a Gist.
    • Client-side license verification with machine ID generation.
  • Authentication: Utilizes GitHub Personal Access Tokens for secure API access.
  • Customization: Supports customization of User-Agent strings for API requests.

Requirements

Library Installation
Requests pip install requests

Installation

Install with pip

pip install gistlick

Quick Start

Here's a quick example to get you started with GistLick:

from gistlick import GistLick, GistLickey

# --- Initialize GistLick ---
# Replace 'YOUR_GITHUB_TOKEN' with your actual GitHub Personal Access Token.
# Ensure your token has the 'gist' scope enabled.
gist_lick = GistLick(token='YOUR_GITHUB_TOKEN')

# Verify authentication
if gist_lick.user:
    print(f"Authenticated as: {gist_lick.user.get('user')} (ID: {gist_lick.user.get('id')})")
else:
    print("Authentication failed. Please check your GitHub token.")
    exit()

# --- Gist Management: Create a new Gist ---
try:
    new_gist = gist_lick.create_gist(
        name='my_licenses.json',
        public=False,
        description='A private Gist to store license keys'
    )
    print(f"\nCreated Gist: '{new_gist.get('name')}' (ID: {new_gist.get('id')})")
    print(f"Raw URL: {new_gist.get('url')}")
    my_gist_id = new_gist.get('id')
except Exception as e:
    print(f"\nError creating Gist: {e}")
    my_gist_id = None # Ensure my_gist_id is set to None on failure

if my_gist_id:
    # --- License Management: Create a new License ---
    # Using GistLickey to get a sample machine ID for demonstration
    gist_lickey_client = GistLickey(gist_url=f"[https://gist.githubusercontent.com/](https://gist.githubusercontent.com/){gist_lick.user.get('user')}/{my_gist_id}/raw")
    
    try:
        new_license = gist_lick.create_license(
            id=my_gist_id,
            user='client_app_user_1',
            plan='premium',
            machine=gist_lickey_client.get_machine_id(), # Generate machine ID
            expired=30 # Expires in 30 days
        )
        print(f"\nCreated License: {new_license.get('license')}")
        print(f"For user: {new_license.get('user')}, expires: {new_license.get('expired')}")
    except Exception as e:
        print(f"\nError creating License: {e}")

    # --- License Management: Verify a License ---
    if new_license:
        try:
            # Note: For verification, the GistLickey needs the raw Gist URL
            # The URL points to the raw content, not the GitHub API itself.
            verify_result = gist_lickey_client.verify_license(new_license.get('license'))
            print(f"\nLicense Verification: {verify_result.get('message')}")
            print(f"Status: {'Valid' if verify_result.get('status') else 'Expired/Invalid'}")
        except Exception as e:
            print(f"\nError verifying License: {e}")

    # --- Clean up: Delete the created Gist (Optional) ---
    try:
        if input("\nDo you want to delete the created Gist? (yes/no): ").lower() == 'yes':
            delete_message = gist_lick.delete_gist(my_gist_id)
            print(f"Gist deleted: {delete_message.get('message')}")
    except Exception as e:
        print(f"\nError deleting Gist: {e}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gistlick-0.0.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gistlick-0.0.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file gistlick-0.0.1.tar.gz.

File metadata

  • Download URL: gistlick-0.0.1.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for gistlick-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7930d9d85bf98b39de08e24d0c97b326d1035ab70f7a78a8028d5348395a7837
MD5 8044c86fdf86e3345cc8e2ef9c7f62de
BLAKE2b-256 540bb721861adfd2af8846460f27ab28ce3142692ad718bfa3fb17026c07007b

See more details on using hashes here.

File details

Details for the file gistlick-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: gistlick-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.15

File hashes

Hashes for gistlick-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6cde4c01b2b6cc4ac199febfbaea8eda31b9c1008cc2661b5182dbd85eb7dd95
MD5 2249f0cf6528fdf06b718021c20d44a6
BLAKE2b-256 00b468b977c4645d534e37e5a0c43a266a9f5ea322d60e5f9453df900d44dd86

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page