- Authorization code + PKCE for browser apps and websites
- Device code for TV, desktop, and native-style clients
/api/platform/v1.
Register your app first
Create a developer app at Get API key. Each app receives a stableclient_id.
- Confidential clients also receive a
client_secret - Public clients use
client_idonly - Every app defines its maximum
allowed_scopes - The approval screen shows the app name and requested scopes before the user approves access
Client types
| Client type | Best for | Credentials | Guidance |
|---|---|---|---|
| Public | Browser apps, native apps, desktop apps, TV apps | client_id | Do not embed a secret you cannot protect |
| Confidential | Server-backed apps and websites | client_id + client_secret | Keep the secret server-side only |
Current scopes
Apps can currently request these scopes:profile:readplayback:readplayback:writeevents:read
scope, PunchPlay grants the app’s configured allowed_scopes.
If a request asks for a scope outside the app’s allowed_scopes, the request fails with invalid_scope.
Flow selection
Use this rule:- Use authorization code + PKCE for browser apps and websites that can redirect a user
- Use device code for TV, desktop, CLI, and native-style clients that cannot handle a normal browser callback cleanly
Authorization code + PKCE
1. Redirect the user to PunchPlay
response_type=codeclient_id=YOUR_CLIENT_IDredirect_uri=YOUR_REGISTERED_REDIRECT_URIcode_challenge=BASE64URL_SHA256_OF_CODE_VERIFIERcode_challenge_method=S256
scope=profile:read playback:read playback:write events:readstate=YOUR_OPAQUE_STATE
redirect_uri with:
codestateif you sent onescope
error. Redirect-based failures may also include request_id so the developer has something concrete to report.
Users can review and revoke approved apps later from https://punchplay.tv/settings/connected-apps.
2. Exchange the code for tokens
client_id only. Confidential apps send both client_id and client_secret.
Successful response:
3. Refresh the access token
Device code
1. Request a device code
client_secret.
Response fields:
| Field | Meaning |
|---|---|
user_code | Short code shown to the user |
device_code | Opaque code your app uses to poll |
verification_uri | Approval page |
verification_uri_complete | Approval page with code prefilled |
verification_uri_qr | QR code image data |
expires_in | Device-code lifetime in seconds |
scope | The scope set that will be attached to issued tokens |
2. Poll the token endpoint
3. Refresh the access token
Authenticated requests
Use the access token in theAuthorization header:
/api/platform/v1.
Debugging auth failures
Platform auth errors include:request_idin the JSON bodyX-PunchPlay-Request-Idin the response headers
request_id- UTC timestamp
- endpoint path
client_id- status code
- raw error body
Security guidance
- Treat
client_secret, refresh tokens, and access tokens as sensitive credentials. - Do not embed
client_secretin native apps, browser apps, or sample code intended for public distribution. - Use public clients when your app cannot safely hold a secret.
- Keep
allowed_scopesas narrow as possible for each app. - Rotate secrets immediately if you suspect they were exposed.
- Deactivate an app if you need to revoke its issued tokens quickly.
- If your app runs entirely in the browser, keep in mind that standard
EventSourceclients cannot attach custom authorization headers.