Skip to content

Login to external services

Loupedeck Configuration UI

Configuration UI gets the current state of the account from the GetPlugins message response (pluginPreferences field).

  • type field defines the preference type (always "Account" in this case).
  • name field is a preference name, unique within plugin preference list. It can contain only letters, numbers, dashes and underscores (^[a-zA-Z0-9_-]+$).
  • displayName should be used as a preferred title (instead of fixed "Account" text).
  • isValid field defines whether the user is logged in or not.
  • isRequired field defines whether login is critical for plugin work.
  • value field contains the user name or email (decided by plugin developer) - UI can show the message e.g. as "You are logged in as {value}"
  • value field can be an empty string or null if there is no login as such (e.g. in the Philips Hue plugin) - UI can show a message e.g. as "You are logged in"
  • loginUrl is a URL behind the login button.
  • loginUrlTitle is the text of the login button.
  • logoutUrl is a URL behind the logout button.
  • logoutUrlTitle is the text of the logout button.
"pluginPreferences": [
{
  "type": "Account",
  "name": "fake-account",
  "value": "Fake User Name",
  "displayName": "Fake account",
  "description": null,
  "isRequired": true,
  "isValid": true,
  "loginUrl": "loupedeck:plugin/Test4/callback/preference/fake/login",
  "loginUrlTitle": "Sign in",
  "logoutUrl": "loupedeck:plugin/Test4/callback/preference/fake/logout",
  "logoutUrlTitle": "Sign out"
}
],

Event

When an user logs in or logs out then UI receives PluginPreferenceChanged event with the plugin name and preference name, e.g.:

{
  "id": 0,
  "name": "PluginPreferenceChanged",
  "responseTime": 0,
  "data": {
    "pluginName": "Test4",
    "preferenceName": "fake"
  },
  "failed": false,
  "errorMessage": "",
  "errorCode": 0
}

Plugins

Account preference

Account preference should be created in the plugin constructor.

Login and logout

When the user clicks the "Login" or "Logout" button in the configuration UI, the plugins get PluginPreferenceAccount.LoginRequested or PluginPreferenceAccount.LogoutRequested event correspondingly.

Normal practice is to subscribe to these events in Plugin.Load() method and unsubscribe from these events in Plugin.Unload() method.

When login or logout is done, plugin should call PluginPreferenceAccount.ReportLogin() or PluginPreferenceAccount.ReportLogout() method correspondingly.

Access denied

If on any attempt to call online service plugin receives an "access denied" response, the plugin should call PluginPreferenceAccount.ReportLogout() method.

Access and refresh tokens

PluginPreferenceAccount class has AccessToken and RefreshToken properties that the plugin case uses to store access and refresh tokens.

  • These properties are persistently stored between Loupedeck sessions.
  • These properties are set in the PluginPreferenceAccount.ReportLogin() method call and cleared in PluginPreferenceAccount.ReportLogout() method call.

Example

Here's an example plugin using the login: https://github.com/Igor-Kotv/VlcPlugin