Authentication
All admin API calls require an authenticated session. The SDK manages tokens automatically after login.
import { ESPRMBase } from "@espressif/rainmaker-admin-sdk";
const auth = ESPRMBase.getAuthInstance();
try { const user = await auth.login("admin@example.com", "password123"); console.log("Logged in:", user);} catch (error) { console.error("Login failed:", error);}After successful login, the SDK stores session tokens and attaches them to all subsequent API requests automatically.
Session Management
Section titled “Session Management”Check Existing Session
Section titled “Check Existing Session”const user = await auth.getLoggedInUser();if (user) { console.log("Session active");}Extend Session
Section titled “Extend Session”const newAccessToken = await ESPRMUser.extendSession(refreshToken);Get Access Token
Section titled “Get Access Token”import { ESPRMUser } from "@espressif/rainmaker-admin-sdk";
const token = await ESPRMUser.getAccessToken();Logout
Section titled “Logout”await auth.logout();Password Management
Section titled “Password Management”Forgot Password
Section titled “Forgot Password”await auth.forgotPassword("admin@example.com");Confirm Forgot Password
Section titled “Confirm Forgot Password”await auth.confirmForgotPassword( "admin@example.com", "newPassword123", "123456" // verification code);Change Password
Section titled “Change Password”await auth.changePassword("oldPassword", "newPassword");Using Admin Modules After Auth
Section titled “Using Admin Modules After Auth”Once authenticated, instantiate any admin module and call its methods directly:
import { ESPRMAdminNode, ESPRMAdminUser } from "@espressif/rainmaker-admin-sdk";
const adminNode = new ESPRMAdminNode();const nodes = await adminNode.getNodes();
const adminUser = new ESPRMAdminUser();const users = await adminUser.getUsers();