Skip to content
Developer docs

Building a plugin

This page describes Revolution release 4.0.0.

On this page
  1. 1. Pick the kind of plugin
  2. 2. Create the project
  3. 3. Check the keys
  4. 4. Register the plugin
  5. 5. Run it
  6. A user interface plugin
  7. A service plugin
  8. 6. Make it yours
  9. Before a customer uses it
Revo Ready

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.

TemplatePlugin typeBackendFrontend
python-reactUser interfacePython 3.11+, FastAPIReact 19, Vite
dotnet-reactUser interface.NET 9, ASP.NET CoreReact 19, Vite
dotnet-serviceService.NET 9, ASP.NET Corenone

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.

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.

Terminal window
npm login
npm create @ukrobotics/revo-plugin@latest sample-report

It 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.

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:

Terminal window
python scripts/make_keys.py # python-react
Terminal window
.\scripts\New-PluginKeys.ps1 # dotnet-react and dotnet-service

Both 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.

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.

  1. Open Settings → Tenant Settings → Plugins and select Add Plugin.

  2. 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.

  3. Check the form. If you are filling it in by hand, these are the fields that matter:

    FieldValue
    Plugin TypeUI plugin (launched from the sidebar) or Service plugin (background, no user)
    Display NameThe name shown in the sidebar
    Launch URLhttp://localhost:4173 while developing. A service plugin has none
    Client IDExactly your EXPECTED_CLIENT_ID
    JWKS (Public Key)The contents of public.jwks.json
    API AccessThe scopes the plugin may use. Nothing is granted by default
  4. 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.

  5. 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.

From the project root, start the backend and the frontend together:

Terminal window
npm run dev

On 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_PATH to the instance’s root certificate, or VERIFY_SSL=false for development only.

Open the .env file in the backend project folder and make sure TENANT_ID is set. The service refuses to start without it.

Terminal window
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.

  • User interface. Replace frontend/src/App.tsx. Leave frontend/src/Revo/ alone, because it holds the plugin side of the handshake and the apiRequest helper. Call your own backend with apiRequest. A plain fetch or 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 IRevoApiClient from the SDK.
  • A 403 with 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.

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.