Skip to content

go license key integration (gin or echo) #94

@abhinav-m22

Description

@abhinav-m22

I want to contribute a minimal example showing how to handle the full license key lifecycle: activation, validation, and deactivation; using the official Polar Go SDK.

Why this is needed

While the repo has basic checkout examples, it lacks a clear reference for "Product Entitlement." This example will show Go developers how to gate features and secure APIs using Polar’s license key system, unlocking monetization for self-hosted software and restricted tools.

Implementation Details

I’ll use the polar-go SDK to implement a standard service-protection pattern:

  1. License Activation Endpoint: A route allowing users to link their purchased license key to their current environment or machine.
  2. Validation Middleware: A custom middleware that intercepts requests to protected routes, validating the provided license key using the Polar Go SDK.
  3. Deactivation Flow: An endpoint to release an active seat, providing a way for users to migrate their license to a different instance.
  4. Webhook Synchronization: Integration that listens for Polar events to automatically track when new licenses are issued or benefits are granted.
  5. Configurable Environment: A clear setup for sandbox and production modes via environment variables.

Tech Stack: Go 1.22+, Gin/Echo, Polar Go SDK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions