Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Google IAP Error: Authentication is required. Huh?
Started by J. A. Whye Jan 12 2015 02:54 PM

54 replies to this topic
android iap in-app purchase authentication google play
[TOPIC CONTROLS]
Page 2 of 3 1 2 3
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

smithsun00

[GLOBAL: userInfoPane.html]
smithsun00
  • Enthusiast

  • 87 posts
  • Corona SDK

That is how it is suppose to work. I mean when you get "authentication required..." it is not because you are connected with your publisher account.



[TOPIC: post.html]
#27

jose.castanheira2

[GLOBAL: userInfoPane.html]
jose.castanheira2
  • Enthusiast

  • 41 posts
  • Corona SDK

I'm having the same problem, I tried making the purchase with every account I have and on different devices and I always get that error. Here's the log:

I/Corona  (25676): PURCHASE ****************************************************
*****************
D/Finsky  (24174): [14769] InAppBillingUtils.getPreferredAccount: (myapp name): Account from first account - [ieJC9jZQt-43Mx7723-cXNCET8U]
E/Parcel  (  679): Class not found when unmarshalling: com.google.android.finsky
.billing.lightpurchase.PurchaseParams, e: java.lang.ClassNotFoundException: com.
google.android.finsky.billing.lightpurchase.PurchaseParams
I/CustomFrequencyManager(  679): newFrequencyRequest  - mFrequency = 1350000, mT
imeoutMs = -1, mPkgName = ACTIVITY_RESUME_BOOSTER@4
I/CustomFrequencyManager(  679): Boost Request from package = ACTIVITY_RESUME_BO
OSTER@4 frequency : 1350000type = 6
I/CustomFrequencyManager(  679): !! pkgName = ACTIVITY_RESUME_BOOSTER@4
I/CustomFrequencyManager(  679): Request from package name pkgName = ACTIVITY_RE
SUME_BOOSTER@4
I/CustomFrequencyManager(  679): mContext is Not Null  mContext.pkgName = androi
d
I/CustomFrequencyManager(  679): 2 Old token will be reused!
I/CustomFrequencyManager(  679): CPUDVFSControlRequest : doFrequencyRequest::  =
 1350000 Timeout : -1
I/power   (  679): *** acquire_dvfs_lock : lockType : 1  freq : 1350000
D/qdmemalloc(  245): ion: Mapped buffer base:0x48f3f000 size:1835008 fd:75
D/CustomFrequencyManagerService(  679): acquireDVFSLockLocked : type : DVFS_MIN_
LIMIT  frequency : 1350000  uid : 1000  pid : 679  pkgName : ACTIVITY_RESUME_BOO
STER@4
W/ActivityManager(  679): mDVFSHelper.acquire()
W/ContextImpl(  679): Calling a method in the system process without a qualified
 user: android.app.ContextImpl.sendBroadcast:1336 com.android.server.am.Activity
Stack.startActivityUncheckedLocked:4452 com.android.server.am.ActivityStack.star
tActivityLocked:3936 com.android.server.am.ActivityStack.startActivityMayWait:46
16 com.android.server.am.ActivityManagerService.startActivityInPackage:3135
D/qdmemalloc(  245): ion: Mapped buffer base:0x40057000 size:4096 fd:90
D/qdmemalloc(  245): ion: unmap_buffer base:0x0 size:1835008 offset:0 fd:75
D/qdmemalloc(  245): ion: unmap_buffer base:0x0 size:4096 offset:0 fd:90
E/MP-Decision( 1509): num online cores: 1 reqd : 2 available : 4 rq_depth:1.4000
00 hotplug_avg_load_dw: 72
E/MP-Decision( 1509): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000
000
D/dalvikvm(  679): GC_FOR_ALLOC freed 1432K, 20% free 85121K/105812K, paused 191
ms, total 191ms
D/SensorManager(25676): unregisterListener::
D/Sensors (25676): Remain listener = Sending .. normal delay 200ms
I/Sensors (25676): sendDelay --- 200000000
I/SensorService(  679): info.selectDelay() ns=20000000
D/SensorService(  679): SensorDevice::setDelay, Return(true 1, false 0) =  1
D/SensorManager(25676): JNI - sendDelay
I/SensorManager(25676): Set normal delay = true
D/SensorService(  679): SensorDevice::activating sensor handle=0 ns=20000000
W/ContextImpl(  679): Calling a method in the system process without a qualified
 user: android.app.ContextImpl.sendBroadcast:1336 com.android.server.am.Activity
Stack.startPausingLocked:1315 com.android.server.am.ActivityStack.resumeTopActiv
ityLocked:2377 com.android.server.am.ActivityStack.resumeTopActivityLocked:2163
com.android.server.am.ActivityStack.resumeTopActivityLocked:2149


[TOPIC: post.html]
#28

nischal.srinivas

[GLOBAL: userInfoPane.html]
nischal.srinivas
  • Enthusiast

  • 52 posts
  • Corona SDK

Hi Jose,

 

Did you publish your app?, i was facing similar issue, but once i published my app (as alpha) everything worked fine.



[TOPIC: post.html]
#29

smithsun00

[GLOBAL: userInfoPane.html]
smithsun00
  • Enthusiast

  • 87 posts
  • Corona SDK

Hey, Jose

Look it might be confusing. There are a lot of reasons why this error can happen. The log is not helpful as it may seem to many people.

Most errors shown if not all has nothing to do with your problem or your app at all.

I kind of struggled with it until I solved my problem, which was actually very simple and ediotic mistake by my part. 

What I learned that may cause this error:

1- Make sure you have published your app in beta or alpha version. don't just upload it. press the publish button.

2- Make sure you 'Activate' your in-app purchases Items.

3- The names of your items in the shop must!!! match the names of your items when you call for 'purchase'. (e.g. "com.mycompany.myapp.item_a". that was my mistake.)

4- maybe this has nothing to do with that but make sure to publish and build under different app name than your other apps, and use a new keystore for it. (just create one with 'keytool', it is pretty easy).

 

As far as I can remember those where some of the problems I managed to look up while trying to solve mine. good luck.



[TOPIC: post.html]
#30

jose.castanheira2

[GLOBAL: userInfoPane.html]
jose.castanheira2
  • Enthusiast

  • 41 posts
  • Corona SDK

thanks nischal.srinivas and thanks smithsun00 for the detailed reply.

I already have my app published for beta.

How do I activate the in-app purchase items? I already have a list of them but I can't find where to activate, or maybe I already did.

In the code I'm calling the "purchase" item with "com.mycompany.myapp.item_a", but I inserted my products in the console with only the name "item_a". Is that a problem? Do I really need to give every item the name "com.mycompany.myapp.item_a"?

And I'm pretty sure my app is not making conflict with the others, they are very different.

 

Thanks again everyone.



[TOPIC: post.html]
#31

smithsun00

[GLOBAL: userInfoPane.html]
smithsun00
  • Enthusiast

  • 87 posts
  • Corona SDK

Yes Jose.

you need to give your items the exact same name. on both side with full "com.company.game.item_a".

I think that is your problem. try it out.



[TOPIC: post.html]
#32

jose.castanheira2

[GLOBAL: userInfoPane.html]
jose.castanheira2
  • Enthusiast

  • 41 posts
  • Corona SDK

Ok, so all the items added to the console must have a product id like "com.company.game.item_a"? Or is that the title?

All my products have id like "item_a", but I'm calling purchases operation like "com.company.game.item_a". If I call the purchase operation with "item_a" will it work? Or do I really need the id like "com.company.game.item_a"? If it is, it will take me some hours to test it after adding them.



[TOPIC: post.html]
#33

smithsun00

[GLOBAL: userInfoPane.html]
smithsun00
  • Enthusiast

  • 87 posts
  • Corona SDK

I think both ways should work. Try this: make a dummy/fake item, which is just a regular item on the store but only for testing porpuses.

make two of them. one with only the name of the item, the other with the full "com.company.game.item_a". Inside your code

when calling for purchase - insert the exact name you used in the store. Test them after the are being created (that should take normally a couple of hours, maybe less until store is updated with your items and updates).  In your code, just comment out a normal item you are selling and place the test items' name. After you are done testing, just remove the test items from the store and use what worked best for you.



[TOPIC: post.html]
#34

jose.castanheira2

[GLOBAL: userInfoPane.html]
jose.castanheira2
  • Enthusiast

  • 41 posts
  • Corona SDK

Thank you so much smithsun00, it worked! The product id needed to be the full app id and name.



[TOPIC: post.html]
#35

smithsun00

[GLOBAL: userInfoPane.html]
smithsun00
  • Enthusiast

  • 87 posts
  • Corona SDK

No problem. I had the same problem, and went crazy while trying to figure out what I did wrong. It was just when I was about to release my game and took me like 3 weeks to find out that little mistake that got away under my nose.

Good luck.



[TOPIC: post.html]
#36

jose.castanheira2

[GLOBAL: userInfoPane.html]
jose.castanheira2
  • Enthusiast

  • 41 posts
  • Corona SDK

Ok, I have another problem now. The transaction callback is only acessed when I cancel a purchase, it is never called when I buy or restore...



[TOPIC: post.html]
#37

nischal.srinivas

[GLOBAL: userInfoPane.html]
nischal.srinivas
  • Enthusiast

  • 52 posts
  • Corona SDK

I have been there! :)

 

Ok first things first,

 

When you try to restore you will get a call back only if you have already purchased the item, otherwise you will not get a call back.

 

And i dont see why you will not get a callback for purchase, perhaps can you put your code here, so that we can actually see what are you doing wrong



[TOPIC: post.html]
#38

nischal.srinivas

[GLOBAL: userInfoPane.html]
nischal.srinivas
  • Enthusiast

  • 52 posts
  • Corona SDK

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.



[TOPIC: post.html]
#39

smithsun00

[GLOBAL: userInfoPane.html]
smithsun00
  • Enthusiast

  • 87 posts
  • Corona SDK

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.



[TOPIC: post.html]
#40

jose.castanheira2

[GLOBAL: userInfoPane.html]
jose.castanheira2
  • Enthusiast

  • 41 posts
  • Corona SDK

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

[TOPIC: post.html]
#41

smithsun00

[GLOBAL: userInfoPane.html]
smithsun00
  • Enthusiast

  • 87 posts
  • Corona SDK

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.



[TOPIC: post.html]
#42

jose.castanheira2

[GLOBAL: userInfoPane.html]
jose.castanheira2
  • Enthusiast

  • 41 posts
  • Corona SDK

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.



[TOPIC: post.html]
#43

benyemi

[GLOBAL: userInfoPane.html]
benyemi
  • Observer

  • 23 posts
  • Corona SDK

Hey OP,

 

I had this same error message pop up when testing IAP a few days ago.  

 

The fix was to uploaded a beta apk, with all the proper permissions, and made it live. 

 

Good luck!

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



[TOPIC: post.html]
#44

J. A. Whye

[GLOBAL: userInfoPane.html]
J. A. Whye
  • Corona Geek

  • 1,690 posts
  • Corona SDK

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



[TOPIC: post.html]
#45

waltsir

[GLOBAL: userInfoPane.html]
waltsir
  • Contributor

  • 172 posts
  • Corona SDK

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?

[TOPIC: post.html]
#46

smithsun00

[GLOBAL: userInfoPane.html]
smithsun00
  • Enthusiast

  • 87 posts
  • Corona SDK

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.



[TOPIC: post.html]
#47

waltsir

[GLOBAL: userInfoPane.html]
waltsir
  • Contributor

  • 172 posts
  • Corona SDK

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?

[TOPIC: post.html]
#48

smithsun00

[GLOBAL: userInfoPane.html]
smithsun00
  • Enthusiast

  • 87 posts
  • Corona SDK

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.



[TOPIC: post.html]
#49

waltsir

[GLOBAL: userInfoPane.html]
waltsir
  • Contributor

  • 172 posts
  • Corona SDK

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............",
        },
    },
}


[TOPIC: post.html]
#50

smithsun00

[GLOBAL: userInfoPane.html]
smithsun00
  • Enthusiast

  • 87 posts
  • Corona SDK

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.




[topic_controls]
Page 2 of 3 1 2 3
 
[/topic_controls]