Search in sources :

Example 1 with TokenRefreshResponse

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));
    }
}
Also used : TokenRefreshResponse(org.matrix.androidsdk.rest.model.login.TokenRefreshResponse) RequestPhoneNumberValidationResponse(org.matrix.androidsdk.rest.model.RequestPhoneNumberValidationResponse) AccountThreePidsResponse(org.matrix.androidsdk.rest.model.pid.AccountThreePidsResponse) ForgetPasswordResponse(org.matrix.androidsdk.rest.model.ForgetPasswordResponse) Response(retrofit.client.Response) RequestEmailValidationResponse(org.matrix.androidsdk.rest.model.RequestEmailValidationResponse) TokenRefreshParams(org.matrix.androidsdk.rest.model.login.TokenRefreshParams) TokenRefreshResponse(org.matrix.androidsdk.rest.model.login.TokenRefreshResponse)

Aggregations

ForgetPasswordResponse (org.matrix.androidsdk.rest.model.ForgetPasswordResponse)1 RequestEmailValidationResponse (org.matrix.androidsdk.rest.model.RequestEmailValidationResponse)1 RequestPhoneNumberValidationResponse (org.matrix.androidsdk.rest.model.RequestPhoneNumberValidationResponse)1 TokenRefreshParams (org.matrix.androidsdk.rest.model.login.TokenRefreshParams)1 TokenRefreshResponse (org.matrix.androidsdk.rest.model.login.TokenRefreshResponse)1 AccountThreePidsResponse (org.matrix.androidsdk.rest.model.pid.AccountThreePidsResponse)1 Response (retrofit.client.Response)1