This library has been deprecated, and is no longer supported.
Please consider using Auth0 Management API instead.
Client for Guardian Management based on API2
This is an small wrapper arround API2 that help you use the Guardian api.
Configures the client and returns a configured instance that will use
OAuth2 against domain to request the authorization token for
Auth0 Management API, Auth0 Management API must be properly configured
to support this flow. More info
Example
const client = require('guardian-management-client').configure({
tenant: 'mytenant',
region: 'eu' // Valid: eu | us | au,
clientId: // Client ID for a client with access to Auth0 Management API,
clientSecret: // Client secret for the Client ID Provided,
domain: '', // Will be used to get the token and (optionally call api2)
baseUrl: '', // Base url for API2, if not provided will be built as `https://{domain}/api/v2`
});
Configures the client and returns a configured instance
Example
const client = require('guardian-management-client').configure({
tenant: 'mytenant',
region: 'eu' // Valid: eu | us | au,
token: // AUTH0 API2 TOKEN
});
Creates an instance of an enrollment
Example
const enrollment = client.enrollment.create('dev_1234');
Fetchs data of an enrollment
Retrieve fetched / modified data
Not yet applied changes
Fetched / built data without the changes
Deletes an enrollment
Example
enrollment.fetch()
.then((enrollment) => {
const attrs = enrollment.attrs(); // Enrollment attributes (name, id, phone_number, etc)
return enrollment.del()
})
.then(function() {
// Enrollment has been deleted
})
Creates an instance of a factor
Example
const factor = client.factor.create('sms');
Retrieves all factors from server
client.factor.getAll().then((factors) => {
const factor1 = factors[0];
const factor2 = factors[1];
//...
});
Marks a factor as enabled, changes won't be applied until you call .update()
Marks a factor as disabled, changes won't be applied until you call .update()
Retrieve fetched / modified data
Not yet applied changes
Fetched / built data without the changes
Apply changes
Example
client.factor.getAll().then((factors) => {
return factors[0].enable().update();
})
.then(() => {
// Factor has been enabled
});
client.factorProvider.create({ factor: string, provider: string }, [factorProviderData]):FactorProvider
Creates an instance of a factor provider
Example
const factorProvider = client.factor.create({ factor: 'sms', provider: 'twilio' });
Modify factor provider data, changes won't be applied until you call .update()
Retrieve fetched / modified data
Not yet applied changes
Fetched / built data without the changes
Apply changes
Example
const fp = client.factorProvider.create({ factor: 'sms', provider: 'twilio' });
fp.set({ sid: '', ... });
fp.update().then(() => {
...
});
Creates an instance of a factor provider
Example
const user = client.user.create('auth0|1234');
Shortcut method, adds user_metadata.use_mfa = false to the user. This wont be applied until you call update.
Shortcut method, adds user_metadata.use_mfa = true to the user. This wont be applied until you call update.