setDefault

setDefault(source)

Sets the identity source used by login() on non-browser platforms (Node.js and friends), where there’s no UI to run an OAuth-style flow through. Calling this before login() is the non-browser equivalent of the browser’s login page.

Arguments:
  • source – A private key, a keystore filename, or a JSON-encoded keystore string.

The dcp-client CLI argument parser calls this for you when a program is run with --dcp-identity=<source>, so applications built on top of dcp-client’s standard argument handling often don’t need to call this directly.

Example

const identity = require('dcp/identity');

identity.setDefault('<api-key>');
await identity.login();