Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /
io.realm.mongodb

Class Credentials

java.lang.Object
io.realm.mongodb.Credentials

Las credenciales representan un inicio de sesión con un proveedor de inicio de sesión determinado y MongoDB Realm las utiliza para verificar al usuario y otorgar acceso. El proveedor Provider.EMAIL_PASSWORD está habilitado por defecto. Todos los demás proveedores deben estar habilitados en MongoDB Realm para funcionar.

Tenga en cuenta que los usuarios que deseen iniciar sesión usando correo electrónico/contraseña deben registrarse primero utilizando EmailPasswordAuth.registerUser(String, String).

Credentials are used the following way:

// Example
App app = new App("app-id");
Credentials credentials = Credentials.emailPassword("email", "password");
User user = app.loginAsync(credentials, new App.Callback<User>() {
@Override
public void onResult(Result<User> result) {
if (result.isSuccess() {
handleLogin(result.get());
} else {
handleError(result.getError());
}
}
));
}

Tip

  • Authentication Providers

Modificador y Tipo
Clase y descripción

public static final

Modificador y Tipo
Método y descripción

public static Credentials

Creates credentials representing an anonymous user.

public static Credentials

Crea credenciales que representan una autenticación con una clave API de usuario.

public static Credentials

String idToken
)

Creates credentials representing a login using an Apple ID token.

public String

Returns the credentials object serialized as a json string.

public static Credentials

Document arguments
)

Creates credentials representing a remote function from MongoDB Realm using a Document which will be parsed as an argument to the remote function, so the keys must match the format and names the function expects.

public static Credentials

String email,
String password
)

Creates credentials representing a login using email and password.

public static Credentials

String accessToken
)

Creates credentials representing a login using a Facebook access token.

Devuelve el proveedor de identidad utilizado para autenticarse.

public static Credentials

String authorizationCode
)

Creates credentials representing a login using a GoogleAuthType.AUTH_CODE Google access token.

public static Credentials

Crea credenciales que representan un inicio de sesión mediante un token de acceso de Google de un GoogleAuthType determinado.

public static Credentials

jwt (
String jwtToken
)

Crea credenciales que representan un inicio de sesión utilizando un token JWT.

  • Methods inherited from class java.lang.Object : getClass , hashCode , equals , clone , toString , notify , notifyAll , wait , wait , wait , finalize

public static Credentials anonymous ()

Creates credentials representing an anonymous user.Logging the user out again means that data is lost with no means of recovery and it isn't possible to share the user details across devices.

The anonymous user must be linked to another real user to preserve data after a log out.

Devuelve

a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) .

public static Credentials apiKey (
String key
)

Creates credentials representing a login using a user API key.This provider must be enabled on MongoDB Realm to work.

Parámetros

  • key - the API key to use for login.

Devuelve

a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) .

public static Credentials apple (
String idToken
)

Crea credenciales que representan un inicio de sesión mediante un token de ID de Apple. Este proveedor debe estar habilitado en MongoDB Realm para funcionar.

Parámetros

  • idToken - the ID token generated when using your Apple login.

Devuelve

a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) .

public String asJson ()

Returns the credentials object serialized as a json string.

Devuelve

a json serialized string of the credentials object.

public static Credentials customFunction (
Document arguments
)

Creates credentials representing a remote function from MongoDB Realm using a Document which will be parsed as an argument to the remote function, so the keys must match the format and names the function expects.

Este proveedor debe estar habilitado en MongoDB Realm para funcionar.

Parámetros

  • arguments - document containing the function arguments.

Devuelve

a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) .

public static Credentials emailPassword (
String email,
String password
)

Creates credentials representing a login using email and password.

Parámetros

  • email - correo electrónico del usuario que inicia sesión.

  • password - password of the user logging in.

Devuelve

a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) .

public static Credentials facebook (
String accessToken
)

Crea credenciales que representan un inicio de sesión mediante un token de acceso de Facebook. Este proveedor debe estar habilitado en MongoDB Realm para funcionar.

Parámetros

  • accessToken - the access token returned when logging in to Facebook.

Devuelve

a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) .

Devuelve el proveedor de identidad utilizado para autenticarse.

Devuelve

the provider identifying the chosen credentials.

public static Credentials google (
String authorizationCode
)

Creates credentials representing a login using a GoogleAuthType.AUTH_CODE Google access token.

Este proveedor debe estar habilitado en MongoDB Realm para funcionar.

Parámetros

  • authorizationCode - el código de autorización devuelto al iniciar sesión en Google.

Devuelve

a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) .

public static Credentials google (
)

Crea credenciales que representan un inicio de sesión mediante un token de acceso de Google de un GoogleAuthType determinado.

Este proveedor debe estar habilitado en MongoDB Realm para funcionar.

Parámetros

  • token - the access token returned when logging in to Google.

  • type - the access token type

Devuelve

a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) .

public static Credentials jwt (
String jwtToken
)

Creates credentials representing a login using a JWT Token. This token is normally generated after a custom OAuth2 login flow.This provider must be enabled on MongoDB Realm to work.

Parámetros

  • jwtToken - the jwt token returned after a custom login to a another service.

Devuelve

a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) .

Volver

Escucha de autenticación

En esta página