Closed ghost closed 9 years ago
Thanks for your question!
Can you try one of the code examples below?
Change my-username
or my-email
to your valid username or email address and my-password
to the correct password for this account.
For logging in with username and password:
final HashMap<String, String> auth = new HashMap<String, String>();
auth.put("username", "my-username");
auth.put("password", "my-password");
meteorInstance.call("login", auth);
For logging in with email and password:
final HashMap<String, String> auth = new HashMap<String, String>();
auth.put("email", "my-email");
auth.put("password", "my-password");
meteorInstance.call("login", auth);
Please report if this works or if you need furhter help :)
Thank you for your help ! But I can't put meteorInstance.call("login", auth); Because the meteorInstance.call method not accept auth :( . Do you have an Idea ?
Sorry, please try this instead:
meteorInstance.call("login", new Object[] { auth });
As can be seen here: https://github.com/delight-im/Android-DDP/blob/63c5ab065eb2b4ec0e941ed364a8cd147aa0bd73/Android/Source/src/im/delight/android/ddp/Meteor.java#L649
It requires an array of Object
so we have to wrap auth
in Object[]
.
Anyway, you should also specifiy a ResultListener
as the third parameter so that you can be informed of the result:
new ResultListener() {
...
}
Does this work now?
I test with this code final HashMap<String, String> auth = new HashMap<String, String>(); auth.put("email", "myMailAdress"); auth.put("password", "myMailPassword"); Object[] methodArgs = new Object[1]; methodArgs[0] = auth; mMeteor.call("login", methodArgs, new ResultListener() { @Override public void onSuccess(String s) { System.out.println("Success"); } @Override public void onError(String s, String s2, String s3) { System.out.println("Error"); } });
Test url : http://ddptester.meteor.com/
But this return Error :(
The server log Exception while invoking method 'login' Error: Match error: Unknown key in field email I20150317-18:10:55.115(1)? at packages/check/match.js:299:1 I20150317-18:10:55.115(1)? at Function..each..forEach (packages/underscore/underscore.js:113:1) I20150317-18:10:55.115(1)? at checkSubtree (packages/check/match.js:290:1) I20150317-18:10:55.115(1)? at check (packages/check/match.js:32:1) I20150317-18:10:55.115(1)? at [object Object].Accounts.registerLoginHandler.check.user (packages/accounts-password/password_server.js:144:1) I20150317-18:10:55.115(1)? at packages/accounts-base/accounts_server.js:383:1 I20150317-18:10:55.115(1)? at tryLoginMethod (packages/accounts-base/accounts_server.js:186:1) I20150317-18:10:55.115(1)? at runLoginHandlers (packages/accounts-base/accounts_server.js:380:1) I20150317-18:10:55.115(1)? at [object Object].Meteor.methods.login (packages/accounts-base/accounts_server.js:434:1) I20150317-18:10:55.115(1)? at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1599:1) I20150317-18:10:55.116(1)? Sanitized and reported to the client as: Match failed [400]
Have you the same problem ?
Sorry, the email
entry had to be wrapped in another HashMap<String, Object>
entry named user.
You can now use built-in methods from this library to register and login users. Please get one of the latest JARs and then try the following code: https://github.com/delight-im/Android-DDP/blob/81dba4c1ccf77fc12f133abdbc8f595f84fdfb16/Examples/DDP/src/im/delight/android/ddp/examples/MainActivity.java#L63
Does this work for you?
It's work fine !!! Thanks for your help !!!
Hello, I looking for login (mail, password) to meteor server with your app. can you help me ?