Allow end user to login using API

Hi,

I have created a user from /admin/user-list > Add New User but when I was trying to login in the Android app
im creating I was always getting a USER_NOT_FOUND exception.

What I have managed to do and worked for me is calling enabelLogin() from the user service.

Is there an action I can do from the kms admin area when i’m adding a new user to enable login (maybe the Extra Data field ? ) or afterwards? Or maybe from the kmc dashboard ? Or the only way is when the user tries to login from the android app to enable login when I get her credentials ?

The case is : add new user from the kms admin area, user tries to login from the android app.

Thank you again!

Hi,

Please share your code so we can further assist.
In general, a login can be done using the loginByLoginId(loginId, password) function, which is part of the user API.

Hi Jess and sorry for late reply.

I tried a lot but still nothing works for me.
Here is the code

`

 public void loginByloginId(final String email, final String password, final int partnerId,
                             final LoginTaskListener loginTaskListener) {

    final Handler handler = new Handler();

    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            try {
                KalturaUserService userService = new KalturaUserService(client);
                Log.i(TAG, "LOGIN-BY-LOGIN-ID email ==  " + email + "  pass= " +password + " partID == " + partnerId);
                ks = userService.loginByLoginId(email, password, partnerId, 86400, "disableentitlement");
                Log.i(TAG, "KS === " + ks);

                // set the kaltura client to use the received ks as default for all future operations
                client.setSessionId(ks);
                userIsLogin = true;

                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        loginTaskListener.onLoginSuccess();
                    }
                });
            } catch (final KalturaApiException e) {
                e.printStackTrace();
                Log.i(TAG, "Login error: " + e.getMessage() + " error code: " + e.code);
                userIsLogin = false;
                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        loginTaskListener.onLoginError(e.getMessage());
                    }
                });
            }
        }
    };
    new Thread(runnable).start();
}

`

The problem is with the end users ( the users I add from the http://partnerID.mediaspace.kaltura.com/admin/user-list/ ) .

The error message I get is : Login error: Wrong password supplied error code: USER_WRONG_PASSWORD

UPDATE : If I use the loginByLoginId(username, password) I can login but then I dont have permissions to make queries with filters. I get the message : The access to service [playlist->executeFromFilters] is forbidden

**UPDATE 2 ** : The code is below and the user can login to http://partnerID.mediaspace.kaltura.com/admin but cannot login using this code from android app :

    private class AuthorizeTask extends AsyncTask<Void, Void, Void> {
    String ks;

    @Override
    protected Void doInBackground(Void... params) {
        try {
            KalturaUserService userService = new KalturaUserService(client);
            ks = userService.loginByLoginId(username, password);
            Log.i(TAG, "KS === " + ks);

            client.setSessionId(ks);

        } catch (final KalturaApiException e) {
            e.printStackTrace();
            Log.i(TAG, "Login error: " + e.getMessage() + " error code: " + e.code);
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        super.onPostExecute(aVoid);
    }
}

I’d really appreciate any help.