use of com.zype.android.webapi.builder.AuthParamsBuilder in project zype-android by zype.
the class SettingsProvider method isLogined.
public boolean isLogined() {
// Check if Access Token needs to be refreshed
if (isAccessTokenExpiring() == true) {
WebApiManager webApiManager = WebApiManager.getInstance();
AuthParamsBuilder builder = new AuthParamsBuilder();
builder.addClientId();
builder.addClientSecret();
builder.addRefreshToken(SettingsProvider.getInstance().getRefreshToken());
builder.addGrandType("refresh_token");
webApiManager.executeRequest(WebApiManager.Request.AUTH_REFRESH_ACCESS_TOKEN, builder.build());
}
return !TextUtils.isEmpty(getAccessToken()) && !TextUtils.isEmpty(getRefreshToken()) && !TextUtils.isEmpty(getScope()) && !TextUtils.isEmpty(getTokenType()) && getExpiresIn() != -1L;
}
use of com.zype.android.webapi.builder.AuthParamsBuilder in project zype-android by zype.
the class LoginActivity method attemptLogin.
public void attemptLogin() {
hideKeyboard();
String email = emailWrapper.getEditText().getText().toString();
String password = passwordWrapper.getEditText().getText().toString();
if (BuildConfig.DEBUG) {
if (email.length() == 0 && password.length() == 0) {
email = "brian@zypemedia.com";
password = "Password1";
}
}
if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
passwordWrapper.setError(getString(R.string.error_invalid_password));
}
if (TextUtils.isEmpty(email)) {
emailWrapper.setError(getString(R.string.error_field_required));
} else if (!isEmailValid(email)) {
emailWrapper.setError(getString(R.string.error_invalid_email));
} else {
emailWrapper.setErrorEnabled(false);
passwordWrapper.setErrorEnabled(false);
showProgress(true);
AuthParamsBuilder builder = new AuthParamsBuilder();
builder.addUsername(email);
builder.addPassword(password);
builder.addClientId();
builder.addClientSecret();
builder.addGrandType("password");
getApi().executeRequest(WebApiManager.Request.AUTH_RETRIEVE_ACCESS_TOKEN, builder.build());
}
}
use of com.zype.android.webapi.builder.AuthParamsBuilder in project zype-android by zype.
the class LoginActivity method handleRetrieveAccessToken.
@Subscribe
public void handleRetrieveAccessToken(RetrieveAccessTokenEvent event) {
RetrieveAccessToken.RetrieveAccessTokenData data = event.getEventData().getModelData();
SettingsProvider.getInstance().saveAccessToken(data.getAccessToken());
SettingsProvider.getInstance().saveExpiresIn(data.getExpiresIn());
SettingsProvider.getInstance().saveRefreshToken(data.getRefreshToken());
SettingsProvider.getInstance().saveScope(data.getScope());
SettingsProvider.getInstance().saveTokenType(data.getTokenType());
Logger.d("handleRetrieveAccessToken");
AuthParamsBuilder authParamsBuilder = new AuthParamsBuilder();
authParamsBuilder.addToken(data.getAccessToken());
getApi().executeRequest(WebApiManager.Request.TOKEN_INFO, authParamsBuilder.build());
}
Aggregations