All documentation
Authentication

Authentication and Doctor Diagnostics

Test service health, key authentication and channel access before debugging application code.

Multi-language

Overview

When an integration does not work, test the connection before changing application logic. SDK 0.2.0 includes health/auth helpers and a doctor command. Doctor checks the live service, authentication and channel access and reports the failing stage instead of hiding everything behind one generic error.

Setup

JavaScript CLI: 1. Set your PulseGrid environment variables. 2. Run npx pulsegrid doctor. Python CLI: 1. Activate your Python environment. 2. Set the PulseGrid environment variables. 3. Run python -m pulsegrid doctor. Programmatic checks: - JavaScript: pg.health.check(), pg.testAuth() or pg.auth.test() - Python: pg.health.check(), pg.test_auth() or pg.auth.test() If health passes but authentication fails, check the copied API key pair before investigating WebSockets, Redis or application code.

Code example

Authentication and Doctor Diagnostics
JavaScript
const health = await pg.health.check();
const auth = await pg.auth.test();
console.log({ health, auth });

Notes

Common failure meanings: - invalid_public_key: the public key is wrong or no longer exists. - invalid_secret_key/authentication failure: the secret does not match the key. - project mismatch/access failure: the operation targets a project not owned by that key. - rate_limited: wait and retry according to the returned guidance. - timeout/network_error: check network reachability before changing credentials.