Leverage Unkey’s short-lived keys to grant temporary access to digital content (e.g., e-books, videos, or streams), expiring after a set duration.
Many platforms lack simple time-based access controls or rely on complex, time-consuming setups. Unkey offers a quick, dynamic solution for trial versions, short-term access, or educational content management.
Ideal for educational platforms, research papers, and subscription-based news services.
- Security: Content remains server-side, with access controlled by expiring API keys.
- Control: Easily revoke or limit access by managing key lifespans.
- Scalability: Suited for serverless or distributed systems.
This demo provides time-limited access to specific pages of a PDF, without allowing full downloads. Each page request is authenticated with Unkey, ensuring access is controlled and expires as needed. The app streams individual PDF pages as users navigate through them.
- Go to /settings/root-keys and click on the "Create New Root Key" button.
- Enter a name for the key.
- Select the following workspace permissions:
create_key,read_key,encrypt_keyanddecrypt_key. - Click "Create".
- Go to https://app.unkey.com/apis and click on the "Create New API" button.
- Give it a name.
- Click "Create".
- Clone the repository
git clone [email protected]:unrenamed/unkey-pdf-view
cd unkey-pdf-view- Install the dependencies
pnpm install- Create a
.envor.env.localfile and add the following:
UNKEY_ROOT_KEY=your-root-key
UNKEY_EBOOK_API_ID=your-ebook-api-id- Start the server
pnpm dev- Open your browser and go to http://localhost:3000