Building a plugin
This page describes Revolution release 4.0.0.
On this page
Hi, I'm Revo
Ask me anything about Revolution. My answers link the pages they come from.
This walkthrough takes a plugin from an empty folder to running inside Revolution. It uses the
starter templates, which wrap the UKRobotics.Plugins.Sdk package, so the token exchange described
on Authentication is already written for you.
1. Pick the kind of plugin
Section titled “1. Pick the kind of plugin”| Template | Plugin type | Backend | Frontend |
|---|---|---|---|
python-react | User interface | Python 3.11+, FastAPI | React 19, Vite |
dotnet-react | User interface | .NET 9, ASP.NET Core | React 19, Vite |
dotnet-service | Service | .NET 9, ASP.NET Core | none |
The type is a real choice. A user interface plugin is a page operators open from the sidebar. A
service plugin runs with nobody watching, for example a timer or a sync with another system.
Revolution refuses client_credentials to a user interface plugin and the authorization code flow
to a service plugin, and the type cannot be changed after the plugin is registered.
2. Create the project
Section titled “2. Create the project”The scaffolder is published in the ukrobotics npm organisation, which is private. Log in with an
account that is a member of it first, or the next command fails with a 404. Your UK Robotics
contact can tell you more about access.
npm loginnpm create @ukrobotics/revo-plugin@latest sample-reportIt asks for the plugin type, the backend (when there is a choice), a plugin name, your
organisation, the client id and the Revolution host. The client id defaults to
com.<organisation>.<plugin-name>, and the host defaults to https://labrevolution.com. Give the
origin of the Revolution your customer uses (see Conventions).
For a service plugin it also asks for a tenant id. It then offers to install dependencies and to
generate your signing keys. Answer yes to both.
When it finishes you have a configured project with its .env files filled in, and a
revo-plugin-registration.json file at the project root.
3. Check the keys
Section titled “3. Check the keys”Your plugin proves who it is with a key pair. The scaffolder’s key generation writes keys/private.pem and
keys/public.jwks.json under backend/, and puts the key’s path and kid into .env.
If you skipped it, generate the keys now, from the backend folder:
python scripts/make_keys.py # python-react.\scripts\New-PluginKeys.ps1 # dotnet-react and dotnet-serviceBoth compute the kid the same way, so a pair from either tool registers identically. Neither
script edits .env: each prints the values to set. Copy them into the backend’s .env
(backend/.env for python-react, backend/<project>/.env for the .NET templates) before you
start the backend: PRIVATE_JWT_KEY_PATH, PRIVATE_JWT_KEY_KID, and PLUGIN_JWT_SECRET_KEY for a
UI plugin or TENANT_ID for dotnet-service. Until then a .NET backend cannot load its private
key, and a kid that does not match fails every token exchange.
After generating or rotating keys, run npm run registration (the React templates)
or node scripts/registration.mjs (dotnet-service) from the project root to refresh the JWKS in
revo-plugin-registration.json.
4. Register the plugin
Section titled “4. Register the plugin”Registration happens in the customer’s tenant, under Settings → Tenant Settings → Plugins, and needs
write:tenant-settings. If you do not hold that in the tenant, send the administrator your
revo-plugin-registration.json. It holds only public values.
-
Open Settings → Tenant Settings → Plugins and select Add Plugin.
-
Select Import from JSON, paste the contents of
revo-plugin-registration.json(or upload the file) and select Import. This fills in the form. Nothing is saved yet. -
Check the form. If you are filling it in by hand, these are the fields that matter:
Field Value Plugin Type UI plugin (launched from the sidebar) or Service plugin (background, no user) Display Name The name shown in the sidebar Launch URL http://localhost:4173while developing. A service plugin has noneClient ID Exactly your EXPECTED_CLIENT_IDJWKS (Public Key) The contents of public.jwks.jsonAPI Access The scopes the plugin may use. Nothing is granted by default -
Under API Access, tick the scopes your plugin needs, from the scope catalogue. Grant as few as you can. A service plugin gets exactly what is ticked here. A user interface plugin gets those scopes narrowed to what the person who opens it may do. The service template’s example worker needs
devices:read. -
Make sure Is Enabled is on, then save.
Two optional settings narrow who and what. Visible To limits which capabilities see a user interface plugin in the sidebar, and empty means everyone. Restrict to specific devices limits direct device calls to the devices you name. It does not limit what a schedule moves once the plugin starts one.
The Client ID and the kid in the JWKS must match your .env. A mismatch fails every token
request with invalid_grant, which gives no further detail, so check them first when nothing
works.
5. Run it
Section titled “5. Run it”A user interface plugin
Section titled “A user interface plugin”From the project root, start the backend and the frontend together:
npm run devOn Windows, run node scripts/dev.mjs instead, because npm there hands back the prompt while the
two halves are still stopping. The frontend is at http://localhost:4173. The Python backend
listens on port 8000 and the .NET backend on port 8002.
Open Revolution and select the plugin in the sidebar. The page shows the tenant and the user who launched it. That means the frame handshake and the token exchange both worked.
- Blank frame, no error. Chromium browsers ask before a hosted site may load anything from your machine. Choose Allow on the “Local network access” prompt at the left of the address bar.
- Certificate error against a local Revolution. A self-signed certificate fails verification.
Set
CA_BUNDLE_PATHto the instance’s root certificate, orVERIFY_SSL=falsefor development only.
A service plugin
Section titled “A service plugin”Open the .env file in the backend project folder and make sure TENANT_ID is set. The service
refuses to start without it.
dotnet run --project backend\<Company>.Plugins.<PluginName>Within a few seconds the log shows a device count. That means the client_credentials exchange and
an API call both worked.
6. Make it yours
Section titled “6. Make it yours”- User interface. Replace
frontend/src/App.tsx. Leavefrontend/src/Revo/alone, because it holds the plugin side of the handshake and theapiRequesthelper. Call your own backend withapiRequest. A plainfetchor curl call is refused by the same-origin check. - Your own endpoints. Put the authentication gate on every one:
Depends(get_current_user)in Python,.AddEndpointFilter<PluginAuthFilter>()on the route group in .NET. The same-origin check is not authentication. - Service. Replace the example worker with your own, taking
IRevoApiClientfrom the SDK. - A
403with an empty body. See When it fails. The cause is a missing scope, a grant the customer narrowed, or a device outside the allowed list. For a user interface plugin it can also be that the person who launched it lacks the capability behind the scope. - Finding endpoints. The API Reference lists every route that accepts a plugin token.
Before a customer uses it
Section titled “Before a customer uses it”The development setup is not a deployment. Serve a user interface plugin over HTTPS, with the frontend and the API on the same origin, because Revolution is served over HTTPS and blocks a plain HTTP frame. Change the Launch URL in the registration to match. The .NET user interface template can serve the built frontend and terminate TLS itself. The Python template keeps access tokens in memory, so a restart signs everyone out, and it does not work across several processes until you back that store with something shared.