Add UniFi Protect API Key Only connection mode - #2132
Open
nberardi wants to merge 3 commits into
Open
Conversation
Support authenticating with a UniFi OS Integration API key via the public Protect Integration API, similar to Home Assistant's API-key-only mode, while keeping the existing local user account path. API Key Only currently covers cameras (RTSPS streams, snapshots, detections) and lights; sensors, locks, intercom, privacy masks, and dynamic bitrate remain local-user features. Co-authored-by: Nick Berardi <me@nickberardi.com>
The API-key-only path was calling getBootstrap twice after login, which exceeded UniFi's 10 req/s public Integration API limit and returned 429. A failed second bootstrap then reset still-connecting websockets; closing a CONNECTING ws emits an error with no listener and crashed the plugin. - Bootstrap only once after login - Rate-limit and retry public API requests on 429 - Fetch cameras/lights sequentially; prime RTSPS with GET-only at bootstrap - Safely terminate CONNECTING websockets on reset Co-authored-by: Nick Berardi <me@nickberardi.com>
Co-authored-by: Nick Berardi <me@nickberardi.com>
9 tasks
Owner
Contributor
Author
|
The reason I created this was primarily selfish:
In regards to your comments, yes the public Integration API still doesn’t cover everything Scrypted needs, primarily PTZ, so Local User remains the full-featured default in the configuration. This PR keeps that path unchanged and adds API Key Only as an optional mode for the subset the public API does support today (steams, snapshots, lights). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds an API Key Only connection mode to the UniFi Protect plugin, alongside the existing local user account flow — modeled after Home Assistant’s approach in home-assistant/core#176410.
Connection modes
X-API-KEY) against the public Integration APIAPI keys are created in the UniFi OS local portal under Settings → Control Plane → Integrations.
API Key Only capabilities
Not available in API Key Only (use Local User)
Implementation notes
ProtectPublicApiclient (plugins/unifi-protect/src/public-api.ts) talks to/proxy/protect/integration/v1/*0.2.0Test plan