Log an existing user into the BLOCKv platform.
Three login options are supported, they are:
import io.blockv.common.model.User
import io.blockv.common.internal.net.rest.exception.BlockvException
import io.blockv.core.client.UserManager.TokenType
//login via email or phone
blockv.getUserManager().login(/*user-token,token-type,password*/)
//login via guest id
blockv.getUserManager().loginGuest(/*guest-id*/)
//login via oauth provider (facebook)
blockv.getUserManager().loginOauth(/*provider,oAuth-token*/)
Note: You can access the functions through the UserManager
found in your blockv
singleton. See Getting Started
// blockv is the BLOCKv SDK singleton created in getting started
blockv.getUserManager()
.login("john.doe@example.com", UserManager.TokenType.EMAIL, "secret")
.subscribe(user -> {/*Success*/},
throwable -> {/*Failure*/});
// blockv is the BLOCKv SDK singleton created in getting started
blockv.getUserManager()
.login("+11234567890", UserManager.TokenType.PHONE_NUMBER, "secret")
.subscribe(user -> {/*Success*/},
throwable -> {/*Failure*/});
It is also possible to login using a guest_id
. In the case where a vAtom was sent to a user that is not yet registered on the BLOCKv platform,
the platform will create a temporary guest_id
. The vAtom receiver can login with the guest_id
as follows:
// blockv is the BLOCKv SDK singleton created in getting started
blockv.getUserManager()
.loginGuest("guest_id")
.subscribe(user ->{/*Success*/},
throwable -> {/*Failure*/});
When logging in via facebook, the token is omitted in the request since, it will be returned by the Facebook oAuth flow.
Instead the oauth_token
received from Facebook as part of the oAuth flow is submitted. The oauth_token
will the be used
to call the Facebook API and find the matching ID returned by Facebook.
// blockv is the Blockv sdk singleton created in getting started
blockv.getUserManager()
.loginOauth("facebook", "Repalce with fb oAuth token")
.subscribe(user -> {/*Success*/},
throwable -> {/*Failure*/});