400: An internal consistency error has occurred: 406: No access token: cannot retrieve account

Viewed 1390

throws an error when i try to get access token exact after phone verified

phoneLogin() this method load the UI and all the process goes perfect but when i try

`if (loginResult.getAccessToken() != null) {

                    Log.e("token", loginResult.getAccessToken().toString());
                    toastMessage = "Success:" + loginResult.getAccessToken().getAccountId();
                }

` this code it throws error is mention below

error:400: An internal consistency error has occurred: 406: No access token: cannot retrieve account

code

    public void phoneLogin() {
        final Intent intent = new Intent(LoginActivity.this, AccountKitActivity.class);
        AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder =
                new AccountKitConfiguration.AccountKitConfigurationBuilder(
                        LoginType.PHONE,
                        AccountKitActivity.ResponseType.CODE); // or .ResponseType.TOKEN


        UIManager uiManager = new SkinManager(SkinManager.Skin.CLASSIC, Color.GRAY, R.drawable.bubble_background, SkinManager.Tint.BLACK, 5);
        configurationBuilder.setUIManager(uiManager);

        // ... perform additional configuration ...
        intent.putExtra(
                AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION,
                configurationBuilder.build());
        startActivityForResult(intent, APP_REQUEST_CODE);
    }
@Override
    protected void onActivityResult(
            final int requestCode,
            final int resultCode,
            final Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == APP_REQUEST_CODE) { // confirm that this response matches your request
            AccountKitLoginResult loginResult = data.getParcelableExtra(AccountKitLoginResult.RESULT_KEY);
            String toastMessage;
            if (loginResult.getError() != null) {
                toastMessage = loginResult.getError().getErrorType().getMessage();
                //  showErrorActivity(loginResult.getError());
                Log.e("error", loginResult.getError().toString());
            } else if (loginResult.wasCancelled()) {
                toastMessage = "Login Cancelled";
            } else {
                if (loginResult.getAccessToken() != null) {
                    Log.e("token", loginResult.getAccessToken().toString());
                    toastMessage = "Success:" + loginResult.getAccessToken().getAccountId();
                } else {
                    toastMessage = String.format(
                            "Success:%s...",
                            loginResult.getAuthorizationCode().substring(0, 10));
                }

                // If you have an authorization code, retrieve it from
                // loginResult.getAuthorizationCode()
                // and pass it to your server and exchange it for an access token.

                // Success! Start your next activity...
                // goToMyLoggedInActivity();
                Log.d("success", toastMessage);
                Toast.makeText(this, "success", Toast.LENGTH_LONG).show();
                try {
                    AccountKit.getCurrentAccount(new AccountKitCallback<Account>() {
                        @Override
                        public void onSuccess(Account account) {
                            String accountKitId = account.getId();

                            // Get phone number
                            PhoneNumber phoneNumber = account.getPhoneNumber();
                            String phoneNumberString = phoneNumber.toString();
                            SessionManager sessionManager = new SessionManager(getApplicationContext());
                            sessionManager.setPhone(phoneNumberString);
                            startActivity(new Intent(LoginActivity.this, MobileVerification.class));
                            finish();
                        }

                        @Override
                        public void onError(AccountKitError accountKitError) {

                        }
                    });
                } catch (Exception e) {
                    Log.d("catch", e.toString());
                }

            }

            // Surface the result to your user in an appropriate way.

        }
5 Answers
Related