Los SDK de dispositivos Atlas están obsoletos. Consulte
deprecation page for details.
Puede administrar una clave API de usuario con una instancia de autenticación de clave API de usuario, a la que puede acceder a través de la clave API del usuario. Propiedad apiKeysAuth.
You can create a user API key with the API key auth instance's createAPIKey method.
Advertencia Store the API Key Value El SDK solo devuelve el valor de la clave API del usuario al crearla. Asegúrese de almacenarla. key valor de forma segura para que puedas usarlo para iniciar sesión.
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.
RLMApp *app = [RLMApp appWithId:YOUR_APP_ID]; RLMUser *user = [app currentUser]; RLMAPIKeyAuth *client = [user apiKeysAuth];
[client createAPIKeyWithName:@"someKeyName" completion:^(RLMUserAPIKey *apiKey, NSError *error) { if (error != nil ) { } else { } }];
let app = App (id: YOUR_APP_SERVICES_APP_ID )
let user = app.currentUser! let client = user.apiKeysAuth
client.createAPIKey(named: "someKeyName" ) { (apiKey, error) in guard error == nil else { print ("Failed to create key: \(error ! ) " ) return } }
Puede buscar una clave API de usuario con el método fetchAPIKey de la instancia de autenticación de clave API.
RLMApp *app = [RLMApp appWithId:YOUR_APP_ID]; RLMUser *user = [app currentUser]; RLMAPIKeyAuth *client = [user apiKeysAuth];
NSError *error = nil ;RLMObjectId *objectId = [[RLMObjectId alloc] initWithString:@"someObjectId" error:&error]; [client fetchAPIKey:objectId completion:^(RLMUserAPIKey *apiKey, NSError *error) { if (error != nil ) { } else { } }];
[client fetchAPIKeysWithCompletion:^(NSArray <RLMUserAPIKey *> *keys, NSError *error) { if (error != nil ) { } else { for (RLMUserAPIKey *key in keys) { } } }];
let app = App (id: YOUR_APP_SERVICES_APP_ID )
let user = app.currentUser! let client = user.apiKeysAuth
client.fetchAPIKey(ObjectId ("00112233445566778899aabb" )) { (maybeApiKey, error) in }
client.fetchAPIKeys { (keys, error) in guard error == nil else { fatalError ("Failed to fetch keys: \(error ! ) " ) } for key in keys! { print (key.name) } }
Puedes habilitar o deshabilitar una clave API de usuario con los métodos enableAPIKey y disableAPIKey de la instancia de autenticación de clave API.
RLMApp *app = [RLMApp appWithId:YOUR_APP_ID]; RLMUser *user = [app currentUser]; RLMAPIKeyAuth *client = [user apiKeysAuth];
RLMObjectId *objectId = [[RLMObjectId alloc] initWithString:@"00112233445566778899aabb" error:nil ]; [client enableAPIKey:objectId completion:^(NSError *error) { }];
RLMUserAPIKey *apiKey;
[client disableAPIKey:[apiKey objectId] completion:^(NSError *error) { }];
let app = App (id: YOUR_APP_SERVICES_APP_ID )
let user = app.currentUser!
let client = user.apiKeysAuth
client.enableAPIKey(ObjectId ("00112233445566778899aabb" )) { (error) in }
let apiKey: UserAPIKey ?
client.disableAPIKey(apiKey! .objectId) { (error) in }
Puede eliminar una clave de usuario de la API con la instancia de autenticación de la clave API utilizando el método deleteAPIKey .
RLMApp *app = [RLMApp appWithId:YOUR_APP_ID]; RLMUser *user = [app currentUser]; RLMAPIKeyAuth *client = [user apiKeysAuth];
RLMUserAPIKey *apiKey;
[client deleteAPIKey:[apiKey objectId] completion:^(NSError *error) { }];
let app = App (id: YOUR_APP_SERVICES_APP_ID )
let user = app.currentUser! let client = user.apiKeysAuth
let apiKey: UserAPIKey ?
client.deleteAPIKey(apiKey! .objectId) { (error) in guard error == nil else { print ("Failed to delete key: \(error ! ) " ) return } }