Navigation

Create & Manage API Keys

Overview

The Node SDK includes a client object that allows you to manage API keys associated with the API Key authentication provider.

Create a User API Key

const key: Realm.AuthProviders.ApiKey = await app.auth.apiKey.create("apiKeyName");
const key = await app.auth.apiKey.create("apiKeyName");

Look up a User API Key

// List all of a user's keys
const keys: Realm.AuthProviders.ApiKey[] = await app.auth.apiKey.list();

// Get a specific key by its ID
const keyId = "5eb5931548d79bc784adf46e";
const key: Realm.AuthProviders.ApiKey = await app.auth.apiKey.get(keyId);
// List all of a user's keys
const keys = await app.auth.apiKey.list();
// Get a specific key by its ID
const keyId = "5eb5931548d79bc784adf46e";
const key = await app.auth.apiKey.get(keyId);

Enable or Disable an API Key

const keyId = "5eb5931548d79bc784adf46e";

// Enable the User API Key
await app.auth.apiKey.enable(keyId);

// Disable the User API Key
await app.auth.apiKey.disable(keyId);
const keyId = "5eb5931548d79bc784adf46e";

// Enable the User API Key
await app.auth.apiKey.enable(keyId);

// Disable the User API Key
await app.auth.apiKey.disable(keyId);

Delete an API Key

const keyId = "5eb5931548d79bc784adf46e";

// Delete the User API Key
await app.auth.apiKey.delete(keyId);
const keyId = "5eb5931548d79bc784adf46e";

// Delete the User API Key
await app.auth.apiKey.delete(keyId);