Amira Elsayed Ismail
Amira Elsayed Ismail

Reputation: 9404

in-app billing android return authentication is required when try to subscribe to product

This is my first time to deal with In-App Billing in android 1) I am using API v3 2) I have upload alpha version of my app to be able to test then

enter image description here

3) I have created a subscribe product

enter image description here

4) This is my code to subscribe in the product

mSubscribeButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            try {

                Bundle subscribeIntentBundle = mService.getBuyIntent(3, getPackageName(), "my_product_id", "subs", "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
                PendingIntent pendingIntent = subscribeIntentBundle.getParcelable("BUY_INTENT");

                if (subscribeIntentBundle.getInt("RESPONSE_CODE") == 0) {

                    startIntentSenderForResult(pendingIntent.getIntentSender(), 4002, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
                } else {
                    Toast.makeText(MainActivity.this, "Error Code: " + subscribeIntentBundle.getInt("RESPONSE_CODE"), Toast.LENGTH_SHORT).show();
                }
            } catch (RemoteException e) {
                e.printStackTrace();
            } catch (SendIntentException e) {
                e.printStackTrace();
            }
        }
    });

5) I am getting the following error

enter image description here

Can anyone help please ??

Upvotes: 46

Views: 21466

Answers (7)

a.dibacco
a.dibacco

Reputation: 490

Got same problem with dreadful message:

Authentication is required. You need to sign in to your Google Account.

There were two problems for me:

  1. I tried to buy a product in my code with identifier "com.argonnetech.wordswriting.noads" but the in app product configured in Google Play Developer (GPD) console was named simply "noads"
  2. After changing the name of the in app product in GPD console, I had to switch it to "Active" mode

The it worked. The error message is misleading, an error like "in app item doesn't exist would be better".

Upvotes: 19

herveweb
herveweb

Reputation: 21

Most of the above solutions work, but for those still having this issue, try this:

  • In Android Studio sign your app with the release key (This will create a signed app-release.apk file)
  • Then MAKE SURE you install it on your physical device using adb install path/to/your/app-release.apk (NOT through the Alpha/Beta)

screenshot


Upvotes: 2

Shanki Bansal
Shanki Bansal

Reputation: 1740

Below works for me:

  • Upload draft application as alpha or beta with some version code.
  • Login on device with account which has active subscription.
  • Install signed application on this device with same version as in alpha/beta release.

Upvotes: 1

lenooh
lenooh

Reputation: 10682

The documentation on developer.android.com seems to be outdated.

If you want to test your in-app billing without publishing it, you have to create a google group and add an alpha list of testers. See here: https://support.google.com/googleplay/android-developer/answer/3131213?hl=en

UPDATE

As of mid 2015, this is no longer necessary. You have several new options for testing in the google play developers console.

Upvotes: 2

Pete
Pete

Reputation: 595

In my case the versionCode, versionName, and applicationId were out of sync with the current version of the app on the developer console. I changed these in the build.gradle file. They were different because I rewrote the app in android studio from eclipse. After this, in app billing worked.

Upvotes: 1

NAP-Developer
NAP-Developer

Reputation: 3796

Android Developer testing for in-app purchase account should following this keys.

Base64EncodedPublicKey

// Testing base64EncodedPublicKey

public static final String base64EncodedPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCg" +
 "KCAQEAhNe2XQ70DceAwE6uyYJGK1dIBbZcPdlER/9EEzylr6RDU6tnGj0Tk7kceN03GKvRf/ucT+ERLL3O" +
 "aHR22PXRXLZ17NZ81x6oS2vGmLyXBnjrU/I+asl8cNuLGySaoCdXxPAV+A9g6OG13dk+KY9i0O1roGpFH" +
 "fsAFyKCgSqR0PMJZ1bS+wFFBYf3M4IxgBcxuuZKDmR+MztCgm5N4zc6w2CwFZn3mXeDoTg15mWDU3sZO" +
 "WeRwFeynhV+FCYdDp8DpAkLk1b5IiXYFQ53wxCh/GxiKqBB6uQMmAixFjAcZV1QWfcBABae9vxiV5" +
 "VAEJvOOnhPxnaT9HYadW0pQ/UbJwIDAQAB";

And item purchased key like that

ITEM_PURCHASED

// Testing ITEM_PURCHASED

public static final String ITEM_PURCHASED = "android.test.purchased";

And Starting put this code onCreate() to initialization IabHelper class for in-app purchase,

IabHelper helper = new IabHelper(this, Constants.base64EncodedPublicKey);
helper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
        public void onIabSetupFinished(IabResult result) {
            if (!result.isSuccess()) {
                Log.d("#InAppStartSetup#", "In-app Billing setup failed: " + result);
            } else {
                Log.d("#InAppStartSetup#", "In-app Billing setup successful.");
            }
        }
    });

And finally purchased time on this code handle over here,

helper.launchPurchaseFlow(YOUR_ACTIVITY, Constants.ITEM_PURCHASED,
                YOUR_REQUEST_CODE, mPurchaseFinishedListener, "");

Thank You Guys...

Upvotes: 6

mmw5610
mmw5610

Reputation: 759

I have the same issue previously. Go to your google developer console and make sure your app is PUBLISHED to any version(alpha, beta or prod). Then, the In app purchase will work :)

Upvotes: 40

Related Questions