Skip to main content
You’ll build a one-file Node server for Lantern Walk, the small app from Show the kit’s card table. A person signs in with their Pincast account, taps a button and collects a card. The first person is you.
Every Pincast key is live, so the set and the collect you make here are real, and no call deletes them. The set stays off the Placecard map and front page for anyone who doesn’t hold its cards.Test and live advises a scratch set and a guest for experiments. This page signs a real person in, because sign-in is what it teaches. To keep the run apart from your app’s real sets, use an id such as scratch-lanterns in place of old-town-lanterns in step 3 and in server.mjs.

What you need

  • Node 20.12 or later, and curl. The server installs no packages.
  • A Pincast account to sign in with. You can create one on the sign-in page.
  • A key and a sign-in client for your app, which the first step gets you.

1. Ask for your key and sign-in client

Pincast sets up each app by hand. Write to andrew@pincast.fm with:
  • Your app’s name, and the id you’d like: up to 32 lowercase letters, digits and hyphens.
  • The https addresses of its home page, logo, terms and privacy policy. People see the logo and links to both policies when they approve your app.
  • Its exact sign-in addresses, with no wildcards. For this page, include http://localhost:3000/callback.
Pincast registers your app on id.pincast.fm as a Traditional app, the kind that keeps its secret on your server, and sends you a private file with your key and client.

2. Set up the folder

Copy the values into a file named .env. The file you received calls your key PLACECARD_APP_KEY. Here it’s PINCAST_KEY:
.env
PINCAST_API is the address your server and the curl command call. The key and the client secret stay on your server. Keep .env out of git. Save the set as data/set.json:
data/set.json

3. Register the set

It answers with what the call changed, under your app’s id:

4. Write the server

Save this as server.mjs:
server.mjs
Four routes do the work:
  • GET /signin sends the person to id.pincast.fm with a one-time state and a PKCE challenge.
  • GET /callback exchanges the code for tokens, then sends the ID token to POST /people. That call links the person to your app and answers with their id.
  • POST /collect records the card under that id, with actor.source set to logto.
  • GET / reads what the person holds with GET /sets/{set}/collects.

5. Sign in and collect

Open http://localhost:3000. Use localhost rather than 127.0.0.1, because your sign-in address and the session cookie both name it.
  1. Tap Sign in with Pincast and sign in at id.pincast.fm.
  2. The consent screen names your app and asks for “Your name, username, avatar, and other profile info”. Tap Authorize.
  3. Back in your app, tap Collect Ferry Steps.
Ferry Steps appears under Your cards, read back from Placecard. That’s your first collect. Each tap records one more collect, because the button sends a new time with each one. The card stays listed once, its count goes up, and no call takes a collect back.

Next