Search in sources :

Example 11 with ApiResult

use of org.mediawiki.api.ApiResult in project apps-android-commons by commons-app.

the class MWApi method login.

/**
     * @param username String
     * @param password String
     * @param twoFactorCode String
     * @return String as returned by this.getErrorCodeToReturn()
     * @throws IOException On api request IO issue
     */
public String login(String username, String password, String twoFactorCode) throws IOException {
    //TODO cache this instead of calling again when 2FAing
    String token = this.getLoginToken();
    ApiResult loginApiResult = this.action("clientlogin").param("rememberMe", "1").param("username", username).param("password", password).param("logintoken", token).param("logincontinue", "1").param("OATHToken", twoFactorCode).post();
    return this.getErrorCodeToReturn(loginApiResult);
}
Also used : ApiResult(org.mediawiki.api.ApiResult)

Aggregations

ApiResult (org.mediawiki.api.ApiResult)11 IOException (java.io.IOException)7 MWApi (fr.free.nrw.commons.MWApi)6 ArrayList (java.util.ArrayList)4 RemoteException (android.os.RemoteException)2 Date (java.util.Date)2 AuthenticatorException (android.accounts.AuthenticatorException)1 OperationCanceledException (android.accounts.OperationCanceledException)1 PendingIntent (android.app.PendingIntent)1 ContentProviderClient (android.content.ContentProviderClient)1 ContentValues (android.content.ContentValues)1 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 Cursor (android.database.Cursor)1 Bundle (android.os.Bundle)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 Toast (android.widget.Toast)1 Contribution (fr.free.nrw.commons.contributions.Contribution)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1