use of org.matrix.androidsdk.rest.model.login.TokenRefreshResponse in project matrix-android-sdk by matrix-org.
the class ProfileRestClient method refreshTokens.
/**
* Attempt a user/password registration.
* @param callback the callback success and failure callback
*/
public void refreshTokens(final ApiCallback<Credentials> callback) {
final String description = "refreshTokens";
TokenRefreshParams params = new TokenRefreshParams();
params.refresh_token = mCredentials.refreshToken;
try {
mApi.tokenrefresh(params, new RestAdapterCallback<TokenRefreshResponse>(description, mUnsentEventsManager, callback, null) {
@Override
public void success(TokenRefreshResponse tokenreponse, Response response) {
onEventSent();
mCredentials.refreshToken = tokenreponse.refresh_token;
mCredentials.accessToken = tokenreponse.access_token;
if (null != callback) {
callback.onSuccess(mCredentials);
}
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
Aggregations