use of org.matrix.androidsdk.rest.model.login.TokenLoginParams in project matrix-android-sdk by matrix-org.
the class LoginRestClient method loginWithToken.
/**
* Attempt a user/token log in.
*
* @param user the user name
* @param token the token
* @param txn_id the client transaction id to include in the request
* @param deviceName the device name
* @param callback the callback success and failure callback
*/
public void loginWithToken(final String user, final String token, final String txn_id, String deviceName, final ApiCallback<Credentials> callback) {
// privacy
// final String description = "loginWithPassword user : " + user;
final String description = "loginWithPassword user";
TokenLoginParams params = new TokenLoginParams();
params.user = user;
params.token = token;
params.txn_id = txn_id;
if ((null != deviceName) && !TextUtils.isEmpty(deviceName.trim())) {
params.initial_device_display_name = deviceName.trim();
} else {
params.initial_device_display_name = Build.MODEL.trim();
}
try {
mApi.login(params, new RestAdapterCallback<JsonObject>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
loginWithToken(user, token, txn_id, callback);
}
}) {
@Override
public void success(JsonObject jsonObject, Response response) {
onEventSent();
mCredentials = gson.fromJson(jsonObject, Credentials.class);
callback.onSuccess(mCredentials);
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
Aggregations