Google IAP Error: Authentication is required. Huh?

and one more weird thing that i faced is, if there are any exceptions inside your listener function it will not be thrown (app will not quit).

Lets say you had a nil access somewhere in your listener function and that piece of code is executed in the purchase flow, then you will not get any exceptions (like ‘trying to access nil value’), instead it will skip executing the next lines.

But i think i was getting those exceptions in the console but my app didnt crash.

just make sure there arent any nil access in the listener function.

Yes, it might be something you are trying to do inside the callback function, like unlocking content (items/power-ups etc.). One of those things maybe causing an error which just makes your function not really executed as it should. It can also be something like using ‘restore’ at the start of app, but never end transaction or store initiation which should be called at end of action inside callback function. (if i am not mistaken this is not the case with the new v3 of the google play)

What type of item are you trying to buy? is it consumable like power up or a temporary buff? or is it a permanent item like a sword?

If it is the first or if you did not configure that right inside the consul then you may already have bought it and you just don’t get the “Item already owned” error. 

Try adding something like :

native.showAlert(“error!”, “sorry, transection could not be completed at this time. Please try again later”, {“Okay”});

inside each sections of the callback function where you ask what is the response from the store to locate where is the problem.

Of course change the text inside for each one to separate them from each other.

Thabk you for the quick response everyone. I already put a lot of prints for testing, even at thr beggining of the callback function and it is only called when I cancel the purchase. Whenever I finish a purchase or try ti restore, nothing happens… I’m using a simple code, with a local transactionCallback function

I think it will be a good idea if you paste your code here, like Nischal said. If you do not want to expose anything, you can just make a copy then replace what names you may have there with dummies and paste here, so we can see what is going on there.

Ok, so when I press the button I call the purchase

if(store.isActive) then store.purchase("product id") end

I have called this

local store = require("plugin.google.iap.v3")

And the callback:

local function transactionCallback( event ) print("In transactionCallback\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*", event.transaction.state) local transaction = event.transaction local tstate = event.transaction.state -- --Google does not return a "restored" state when you call store.restore() --You're only going to get "purchased" with Google. This is a work around --to the problem. -- --The assumption here is that any real purchase should happen reasonably --quick while restores will have a transaction date sometime in the past. --5 minutes seems sufficient to separate a purchase from a restore. -- if store.availableStores.google and tstate == "purchased" then local tdate = math.floor( transaction.date /1000 ) local timeStamp = utility.makeTimeStamp(transaction.date,"ctime") if timeStamp + 360 \< os.time() then -- if the time stamp is older than 5 minutes, we will assume a restore. print("map this purchase to a restore") tstate = "restored" print("I think tstate is ", tstate) restoring = false end end if tstate == "purchased" then print("Transaction successful!") myData.unlockVids(transaction.productIdentifier) native.showAlert("Thank you!", "Your support is greatly appreciated!", {"Okay"}) store.finishTransaction( transaction ) elseif tstate == "restored" then print("Transaction restored (from previous session)") myData.unlockVids(transaction.productIdentifier) utility.saveTable(mySettings, "settings.json") store.finishTransaction( transaction ) elseif tstate == "refunded" then print("User requested a refund -- locking app back") myData.lockVids(transaction.productIdentifier) store.finishTransaction( transaction ) elseif tstate == "revoked" then -- Amazon feature print ("The user who has a revoked purchase is", transaction.userId) --Revoke this SKU here: myData.lockVids(transaction.productIdentifier) elseif tstate == "cancelled" then print("User cancelled transaction") store.finishTransaction( transaction ) elseif tstate == "failed" then print("Transaction failed, type:", transaction.errorType, transaction.errorString) store.finishTransaction( transaction ) else print("unknown event") store.finishTransaction( transaction ) end goToMenu() print("done with store business for now") end

And that’s it. I only get the “transactionCallback****…” print when I touch the button, and cancel the purchase interface (tap outside the box, or use the back button). It maybe important to note that I’m requiring the store in two different composer scenes. The callback is in the scene:create and I already removed the “local” from it and nothing changes. Thanks.

Yep everyone, this is the only way to test your app properly. Only the app that you put in beta in the app store will work with the Test account you made. Don’t pull your hair out lol. This whole inApp process is very frustrating

That’s what I decided to do – but in putting up the beta I discovered I was over the 50MB limit and so had to use an expansion file. I could never get the 2-part app to install on my device, so I just gave up on the idea of doing an Android build.

Yesterday (months later) I decided to take a different tack and yanked out some audio (and changed the code referencing them) and got the APK size to under 50MB. Uploaded it as a beta and a few hours later it installed on my device and I was able to make a test IAP purchase with no problem.

 Jay

Same problem because I forgot to publish the beta until now. So I pressed the button “Publish” but where’s the app in Google Play Store to test this beta?

The app is not on google play when you publish it in beta or alpha mode. it just sits in your console and give you the option to activate

tests account, by adding invitations (email addresses of you and/or your friends) to help you test it. 

first define a test group, you can create one using google groups. then add the group’s name to the part where it asks for it inside your app profile in the console and then CHIBAUW!    you should be getting an email within a short time, which inside is the link to download page of your app, so you can use it or/and give it to other testers to download your app.

Be aware though that once you added the group and published it, it will take some time (maybe even an hour or two) for your app to become downloadable inside the link you get.

Thanks for tour help! I still didn’t get the email-link and I’m the only one tester, so can I put directly the apk in my device or I must download it by the link?
On the device test, a tablet, I use a different email than my publisher email but it’s the same person registered (my name/first name) and same credit card. Could it be the reason of that authentication error?

Yes it could be.

You can install it from the computer but make sure it is the same version as the one published.

As far as I remember you must add the e-mail addresses of devices registered as testers. That means 

that they need to get access to the download. If that causes an error when trying to purchase inside app, 

I am not sure about it.

I do know that the error of “error authentication is required” should not occur just because it is you who is testing it.

I used my developer account to test my purchases and the error given should be in this case “the publisher can not make purchases…”

and not the error above. That means you can try using your developer account to test your purchase to get that error.

the authentication problem can be caused by many things:

  • if you did not activated the in-app purchases after submitting them.

  • if you did not write the full name of the item, both in the store and inside your application. e.g: “com.mywebsite.myapp.item1”.

  • if for some reason your account registration in your mobile phone got corrupted and needed to be reset.

  • and many more bugs.

Interesting all what you said!

So, before thinking about an email conflict I should have the error “the publisher can not make purchases…” instead of “error authentication is required”. Well, already 4 days I try to understand why…

I continue my investigations, for now, I’m here:

  • Beta APK is in production (the same uploaded on Google Play and put in the mobile)

  • in-app purchases (managed) activated

  • full name of item in store and code

  • License key copied in config.lua

    local store=require(“store”) local file=require(“lib_file”) local googleIAPv3=false local inapp_data local buy_btn local txt1 local function transactionCallback(evt) local transaction=evt.transaction local tstate=evt.transaction.state if tstate==“purchased” then local tdate=math.floor(transaction.date/1000) local timeStamp=file.makeTimeStamp(transaction.date,“ctime”) if timeStamp+360<os.time() then tstate=“restored” end end if tstate==“purchased” or tstate==“restored” then inapp_data.paid=true file.save(inapp_data,“inapp_data.txt”) buy_btn.isVisible=false txt1.text=“Full Game Purchased!” end txt1.text=tstate --Close the transaction store.finishTransaction(transaction) end local function buyGame(evt) if evt.phase==“ended” then if store.isActive then store.purchase(“com.bitlines.inapp.fullgame”) else txt1.text=“Store not active…” end end return true end ------------------------------------------------- if system.getInfo(“platformName”)==“Android” then store=require(“plugin.google.iap.v3”) googleIAPv3=true end inapp_data=file.load(“inapp_data.txt”) if inapp_data==nil then inapp_data={} inapp_data.paid=false file.save(inapp_data,“inapp_data.txt”) end if googleIAPv3 and not inapp_data.paid then timer.performWithDelay(1000, function() store.init(“google”,transactionCallback); store.restore(); end) --Button to buy the full game buy_btn=display.newRect(200,200,100,100) buy_btn:addEventListener(“touch”,buyGame) end txt1=display.newText("…",150,50,nil,30)

    settings = { orientation = { default = “landscapeRight”, supported = {“landscapeRight”}, }, plugins = { [“plugin.google.iap.v3”] = { publisherId = “com.coronalabs”, supportedPlatforms = { android=true }, }, }, android = { usesPermissions = { “android.permission.INTERNET”, “android.permission.ACCESS_NETWORK_STATE”, “android.permission.RECEIVE_BOOT_COMPLETED”, “com.android.vending.BILLING”, “com.android.vending.CHECK_LICENSE”, }, }, }

    application = { content = { width = 480, height = 800, scale = “letterbox”, xAlign = “center”, yAlign = “center”, }, license = { google = { key = “MIIBIjANB…”, }, }, }

Everything looks quite alright. One thing though and I don’t speak french, I see that the app is in ‘production’ mode, not in alpha/beta.

(you can see it in the picture) 

Did I make the right assumption? 

by the way try not revealing your app google code, like you did in your picture and in your code, it should be private.

Second thing, did you try buying using google’s ’ android.test.purchased’ as an id instead of real purchase id?

Other things that jump into my mind:

- Did you create a new keystore for your app and used it to make your build? (may have nothing to do with your error, but     still will remove other errors connected with duplication of apps using same keystore).

  • Try creating a google group (in google groups), add an email of a friend that can help you test your purchase on his phone (by sending him/her an invitation)    after he accepts go to google play console and add as a test group (the name of the group/address)

if app is in BETA mode or ALPHA mode then that is possible. shortly an link to your app will be available to you to send him, and he can try downloading it and testing it for you.

Your right, it was in Beta but nothing happened so I pressed the button to convert it into “production”… not correct?

Did you mean, the apk must stays in Alpha/Beta then press the button “Publish” (and so, I need to fill all formulars with all screenshots, icons, prices,categories, etc…) just to test this sample code?

What do you mean by " android.test.purchased"? Where do you see this?

Yes. the app should be in alpha/beta mode when you publish it. Production mode means it is now on the google play store available for download by the public.

You do not have to add all details when you publish it in beta mode, but you do need to add all required data like images and so.

You don’t even have to use the real images. just google some images in the same resolutions you need for each one and use it for now. Of course remember to replace it when publishing in production mode. In description just write a word or two.

Look for the Testing with Static Responses section in the middle of the next link: 

http://developer.android.com/google/play/billing/billing_testing.html

it will explain to you the idea of testing demo purchases that just return “purchase”/“cancelled” and the like, instead of real buying.

The link in general will guide you in testing your app on google play.

Ahhh okk!!! It was so confused in my mind (publication and production) and in same time strange to add fake data just to test a sample code! Well, thank you, I think I will reach the goal soon! :slight_smile:

Hi Jay (J. A. Whye),

May I ask how you solved this problem at the end?

I have very troubling experience with this:

  1. IAP worked while app was tested in Alpha.

  2. Promoted my app to Production.

  3. IAP did not worked (adb reported the same problem as in your case).

  4. Tried even on other peoples phones… same error happens to them while app was in production.

  5. Unpublished my app and renamed it.

------------------ NEW APP

  1. Signed new app with completely new keystore (app is published in Alpha).

  2. IAP`s are active in Google Play Console.

8) Same problem again!

One last question:

My app is FREE with IAP inside.

Are following lines required for FREE apps:

main.lua

local licensing = require( "licensing" ) licensing.init( "google" )

build.settings

"com.android.vending.CHECK\_LICENSE",

When the Beta was published my problem was fixed and the app in production workded too. In my build seeting I use also :

“com.android.vending.BILLING”,

Same problem because I forgot to publish the beta until now. So I pressed the button “Publish” but where’s the app in Google Play Store to test this beta?

The app is not on google play when you publish it in beta or alpha mode. it just sits in your console and give you the option to activate

tests account, by adding invitations (email addresses of you and/or your friends) to help you test it. 

first define a test group, you can create one using google groups. then add the group’s name to the part where it asks for it inside your app profile in the console and then CHIBAUW!    you should be getting an email within a short time, which inside is the link to download page of your app, so you can use it or/and give it to other testers to download your app.

Be aware though that once you added the group and published it, it will take some time (maybe even an hour or two) for your app to become downloadable inside the link you get.