use of io.plaidapp.data.api.designernews.model.AccessToken in project sbt-android by scala-android.
the class DesignerNewsLogin method getAccessToken.
private void getAccessToken() {
DesignerNewsService designerNewsService = new RestAdapter.Builder().setEndpoint(DesignerNewsService.ENDPOINT).setRequestInterceptor(new ClientAuthInterceptor(designerNewsPrefs.getAccessToken(), BuildConfig.DESIGNER_NEWS_CLIENT_ID)).build().create(DesignerNewsService.class);
designerNewsService.login(buildLoginParams(username.getText().toString(), password.getText().toString()), new Callback<AccessToken>() {
@Override
public void success(AccessToken accessToken, Response response) {
designerNewsPrefs.setAccessToken(accessToken.access_token);
showLoggedInUser();
setResult(Activity.RESULT_OK);
finish();
}
@Override
public void failure(RetrofitError error) {
Log.e(getClass().getCanonicalName(), error.getMessage(), error);
// TODO snackbar?
Toast.makeText(getApplicationContext(), "Log in failed", Toast.LENGTH_LONG).show();
showLogin();
password.requestFocus();
}
});
}
Aggregations