You can use the Kotlin SDK to create and manage User API keys that allow devices or services to communicate with Realm on behalf of an existing user without requiring the user to re-authenticate.
User API keys are associated with a user object created by another non-anonymous authentication provider. Each user can associate up to 20 user keys with their account.
You can manage keys through the user.apiKeyAuth interface.
To create a new user API key, pass a unique key name to ApiKeyAuth.create(). The created key will be associated with the logged-in user and can be used to interact with Realm on their behalf. You cannot create user API keys for anonymous users.
Warning Store the API Key ValueThe 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.
val user = app.currentUser!!val provider = user.apiKeyAuthval key = provider.create("apiKeyName")
To get a list of all user API keys associated with the logged-in user, call ApiKeyAuth.fetchAll().
To find a specific user API key for the logged-in user, pass the key's id
to ApiKeyAuth.fetch().
val user = app.currentUser!!val provider = user.apiKeyAuthval apiKeys = provider.fetchAll()val apiKey = provider.fetch(key.id)
You can enable or disable a key by calling ApiKeyAuth.enable() or ApiKeyAuth.disable() with the key's id
. You cannot use disabled keys to log in on behalf of the user.
val user = app.currentUser!!val provider = user.apiKeyAuthprovider.enable(key.id)provider.disable(key.id)
To permanently remove a specific user API key, pass the key's id
to ApiKeyAuth.delete(). You cannot recover deleted keys or use them to log in on behalf of the user.
val user = app.currentUser!!val provider = user.apiKeyAuthprovider.delete(key.id)
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