Class Credentials
On this page
io.realm.mongodb
Credentials represent a login with a given login provider, and are used by the MongoDB Realm to verify the user and grant access. The Provider.EMAIL_PASSWORD provider is enabled by default. All other providers must be enabled on MongoDB Realm to work.
Note that users wanting to login using Email/Password must register first using 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>() { public void onResult(Result<User> result) { if (result.isSuccess() { handleLogin(result.get()); } else { handleError(result.getError()); } } )); }
Nested Class Summary
Modifier and Type | Class and Description |
---|---|
public static final |
Method Summary
Modifier and Type | Method and Description |
---|---|
public static Credentials | anonymous () Creates credentials representing an anonymous user. |
public static Credentials | |
public static Credentials | |
public String | asJson () Returns the credentials object serialized as a json string. |
public static Credentials | 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 | Creates credentials representing a login using email and password. |
public static Credentials | |
public Credentials.Provider | Returns the identity provider used to authenticate with. |
public static Credentials | Creates credentials representing a login using a GoogleAuthType.AUTH_CODE Google access token. |
public static Credentials | Creates credentials representing a login using a Google access token of a given GoogleAuthType . |
public static Credentials |
Inherited Methods
Methods inherited from class java.lang.Object :
getClass
,hashCode
,equals
,clone
,toString
,notify
,notifyAll
,wait
,wait
,wait
,finalize
Method Detail
anonymous
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. Returns a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) . |
apiKey
Creates credentials representing a login using a user API key.This provider must be enabled on MongoDB Realm to work. Parameters
Returns a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) . |
apple
Creates credentials representing a login using an Apple ID token.This provider must be enabled on MongoDB Realm to work. Parameters
Returns a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) . |
asJson
customFunction
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. This provider must be enabled on MongoDB Realm to work. Parameters
Returns a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) . |
emailPassword
Creates credentials representing a login using email and password. Parameters
Returns a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) . |
Creates credentials representing a login using a Facebook access token.This provider must be enabled on MongoDB Realm to work. Parameters
Returns a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) . |
getIdentityProvider
public Credentials.Provider getIdentityProvider () |
---|
Returns the identity provider used to authenticate with. Returns the provider identifying the chosen credentials. |
Creates credentials representing a login using a GoogleAuthType.AUTH_CODE Google access token. This provider must be enabled on MongoDB Realm to work. Parameters
Returns a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) . |
Creates credentials representing a login using a Google access token of a given GoogleAuthType . This provider must be enabled on MongoDB Realm to work. Parameters
Returns a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) . |
jwt
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. Parameters
Returns a set of credentials that can be used to log into MongoDB Realm using App.loginAsync(Credentials, App.Callback) . |