Skip to content

Login key that uses the minibrowser#

Example: Calls a special login-telephone-number on key-press. But before it does so, it inquires some codes to insert into the phone number from the user by opening a minibrowser.

The key starts a minibrowser and also serves the login.xml that the minibrowser is tasked to show. The minibrowser sends all the entered data to the key, when user presses "Login" within the minibrowser. The key then uses that data to construct the login-telephone-number and calls it.


This templates needs a valid auth_token, which first needs to be generated via the web ui under Access. Also this generated token is usually different on each device, unless one provisions a fixed token into all devices. Insert the token into the example below (first line of lua-script).

<templates version="42.47.11" patch="true">
  <template prio="10" name="login" icon="@drawable/login">
local auth_token = "bq5nIECs;cgfOPiePDnv;m5Zyv)$3XS;" -- must be a valid api-token listed in phones settings under remoteAccess/authTokens/ .. also see WUI->Access (don't forget to click "save" after you've created a new token)
function onActionUrl(url, body, headers, vars)
  local query = vars.query_map
  local cmd = query.cmd
  debug.log("serving request for login.xml, command="..cmd, "d")
  if cmd == "getXml" then
    return 200, [[<?xml version='1.0' encoding='UTF-8'?>
<Menu xmlns='minibrowser_v01.xsd'>
    <Item id='1'>
            <Help lang="en">internal phone number</Help>
            <Help lang="de">interne Durchwahl</Help>
    <Item id='2'>
            <Help lang="en">enter the PIN</Help>
            <Help lang="de">PIN eingeben</Help>
            <Text lang="en">Cancel</Text>
            <Text lang="de">Abbr.</Text>
            <Quit />
            <Url>;AuthToken=]] .. auth_token .. [[</Url>
  elseif cmd == "doLogin" then
    sip.invite{uri="##8" .. .. "*621" .. query.user .. "#"}
    return 200, [[<?xml version='1.0' encoding='UTF-8'?>
<Dialog xmlns="minibrowser_v01.xsd">
        <Quit on="shown" />
    debug.log("unknow cmd " .. query.cmd)
function onKeyUp()
  -- start the minibrowser
  system.intent{action="android.intent.action.VIEW", component="de.auerswald.minibrowser/.LoadingActivity", data="" .. auth_token}
local mCommandListener = http.listen("login.xml", onActionUrl, true)
key:setLed( "red" )]]>