arlo-api
v1.0.11
Published
Thin API for interacting with Arlo
Downloads
129
Readme
arlo-api
Thin API for interacting with Arlo
Usage
import { Basestation } from './basestation';
const arlo = new Client(config);
// `result` contains necessary information to make further requests
// allowing you to consume just the login result in your library.
const result = await arlo.login();
// Now that arlo has been logged in get the device matching type basestation.
const device = await arlo.getDevice({ deviceType: 'basestation' });
// Construct a new basestation object using our arlo client and the the basestation device.
const basestation = new Basestation(arlo, device);
// Setup event listeners.
basestation.on(ARLO_EVENTS.open, () => {});
basestation.on(ARLO_EVENTS.close, () => {});
// Start event stream.
await basestation.startStream();
Authentication
Currently, email is the only supported MFA method. Caveat I've only tested with Gmail. The library will mark Arlo OTP emails has read. A future release will allow deletion based on a configuration value.
Configuration
{
arloUser: '[email protected]',
arloPassword: 'super secret password',
emailUser: '[email protected]',
emailPassword: 'another secret password',
emailServer: 'imap.gmail.com',
emailImapPort: 993
}
The emailUser
must match one of the configured MFA sources in Arlo.
Gmail
Gmail has certain limitations when trying to connect from a third party app using just username and password. As of May 2022 Google blocked "less secure apps" from accessing their email services. You have to manually opt in and then set up a separate password for a third party. Additionally, you must enable IMAP in Gmail.
Tests
Tests make use of dotenv
package for providing environment variables to the running process.
Create a .env
file at the root of the solution and supply it with whatever your secrets are.
ARLO_USER="[email protected]"
ARLO_PASSWORD="password"
EMAIL_USER="[email protected]"
EMAIL_PASSWORD="password2"
You can also skip the login flow if you've already received a login result object and instead use the following secrets.
SERIAL_NUMBER="serial"
SESSION_EXPIRES="session_expiration"
TOKEN="token"
USER_ID="userId"
And then use the provided _shortCircuitLogin
method.
const arlo = new Client(config);
const loginResult: LoginResult = {
serialNumber: process.env.SERIAL_NUMBER as string,
sessionExpires: Number.parseInt(process.env.SESSION_EXPIRES as string),
token: process.env.TOKEN as string,
userId: process.env.USER_ID as string,
};
arlo._shortCircuitLogin(loginResult);
References
Based on JOHNEPPILLAR's and easton36's great work.