Search in sources :

Example 1 with AccessToken

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();
        }
    });
}
Also used : UserResponse(io.plaidapp.data.api.designernews.model.UserResponse) Response(retrofit.client.Response) AccessToken(io.plaidapp.data.api.designernews.model.AccessToken) DesignerNewsService(io.plaidapp.data.api.designernews.DesignerNewsService) ClientAuthInterceptor(io.plaidapp.data.api.ClientAuthInterceptor) RetrofitError(retrofit.RetrofitError)

Aggregations

ClientAuthInterceptor (io.plaidapp.data.api.ClientAuthInterceptor)1 DesignerNewsService (io.plaidapp.data.api.designernews.DesignerNewsService)1 AccessToken (io.plaidapp.data.api.designernews.model.AccessToken)1 UserResponse (io.plaidapp.data.api.designernews.model.UserResponse)1 RetrofitError (retrofit.RetrofitError)1 Response (retrofit.client.Response)1