To create a new user API key, pass a name that's unique among all of the user's API keys to ApiKeyAuth.create().
const user = app.currentUser;const key = await user.apiKeys.create("apiKeyName");
Warning Store the API Key Value
The SDK only returns the value of the user API key when you create it. Make sure to store the key
value securely so that you can use it to log in.
If you lose or do not store the key
value there is no way to recover it. You will need to create a new user API key.
To get an array that lists all of a user's API keys, call ApiKeyAuth.fetchAll().
To find a specific API key, pass the key's _id
to ApiKeyAuth.fetch().
const user = app.currentUser;const keys = await user.apiKeys.fetchAll();const key = await user.apiKeys.fetch("5eb5931548d79bc784adf46e");
To enable or disable a user API key, pass the key's _id
to ApiKeyAuth.enable() or ApiKeyAuth.disable(). When a key is disabled, it cannot be used to log in on behalf of the user.
const user = app.currentUser;const apiKeys = await user.apiKeys.fetchAll();const keyId = apiKeys[0]["_id"];await user.apiKey.enable(keyId);await user.apiKey.disable(keyId);
To permanently delete a user API, pass the key's _id
to ApiKeyAuth.delete(). Deleted keys cannot be recovered.
const user = app.currentUser;const apiKeys = await user.apiKeys.fetchAll();const keyId = apiKeys[0]["_id"];await user.apiKey.delete(keyId);
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4