Last active
October 16, 2019 07:19
-
-
Save Aschen/5b2f8a5d7c64a674591c5d683442b38d to your computer and use it in GitHub Desktop.
Kuzzle Java SDK Login
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io.kuzzle.sdk.core.Kuzzle; | |
| import io.kuzzle.sdk.core.Options; | |
| Options options = new Options(); | |
| options | |
| .setAutoReconnect(true), | |
| .setPort(7512); | |
| Kuzzle kuzzle = new Kuzzle("106.75.172.117", options, new ResponseListener<Void>() { | |
| @Override | |
| public void onSuccess(Void object) { | |
| Kuzzle kuzzleSdk = (Kuzzle) object; | |
| JSONObject credentials1 = new JSONObject() | |
| .put("username", "liujiang") | |
| .put("password", "123456"); | |
| kuzzle.connect(); | |
| // "local" is the name of the auth strategy, not a server host | |
| kuzzle.login("local", credentials1, 30000, new ResponseListener<JSONObject>() { | |
| @Override | |
| public void onSuccess(JSONObject result) { | |
| // ... | |
| } | |
| } | |
| } | |
| @Override | |
| public void onError(JSONObject error) { | |
| // Handle connection error | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment