IAP Error - Auth requ, although logged in

Target market: Android/Google Play

APIs Enabled: Google Drive, Google Play Game Services

I have an application that (seemingly) correctly logs a google account in, loads up the IAP products correctly, but when attempting to “purchase” the product, I get an authentication required error.

As you can see from image 1, the login box appears (I choose my account, obfuscated for security)

Image 2 shows my logs that I print to screen, it shows;

E.name: login

E.isError: false

E.name: getAccountName

E.isError: false

E.accountName: cxxxxxxxxxxxxxxxx@xxxxxxx

Store is active, and the products load correctly

store.purchase( “hen_do_pack” ) results in image 3: shows auth error… and I cannot fathom why…

Any ideas? (do I need 5x achievements or something weird? I don’t want achievements…)

Happy to share code if you need it, but I don’t think this is code-side, but API-side somewhere…

Code provided anyway;

The workflow is;

func_init -> func_checkCon -> func_login2 -> func_viewUser -> func_initStore -> func_loadProducts -> func_buyStore

 debugText = display.newText(sceneGroup, "", width \* 0.01, height \* 0.01, system.nativeFont, 10) debugText.anchorX, debugText.anchorY = 0, 0 debugText:setFillColor(0.5,0.5,0.5) local gpgs = require( "plugin.gpgs" ) function gpgsListener(event) debugText.text = debugText.text .. "\nGPGS LISTENER;\n".."E.name:"..tostring(event.name).."\nE.isError:"..tostring(event.isError).."\nE.errorMessage:"..tostring(event.errorMessage).."\nE.errorCode:"..tostring(event.errorCode) end function getaccListener(event) debugText.text = debugText.text .. "\nACC LISTENER;\n".."E.name:"..tostring(event.name).."\nE.isError:"..tostring(event.isError).."\nE.errorMessage:"..tostring(event.errorMessage).."\nE.errorCode:"..tostring(event.errorCode).."\nE.accountName"..tostring(event.accountName) end function func\_init(event) if event.phase == "ended" then debugText.text = debugText.text .. "\nAttempting to INIT" gpgs.init( gpgsListener ) end end function func\_checkCon(event) if event.phase == "ended" then connectedToGPGS = gpgs.isConnected() debugText.text = debugText.text .. "\nConnection Status:"..tostring(connectedToGPGS) end end -- function func\_login(event) -- if event.phase == "ended" then -- debugText.text = debugText.text .. "\nLogin with NO params" -- gpgs.login() -- end -- end function func\_login2(event) if event.phase == "ended" then debugText.text = debugText.text .. "\nLogin WITH params" params = { userInitiated = true, listener = gpgsListener, } gpgs.login( params ) end end function func\_logout(event) if event.phase == "ended" then debugText.text = debugText.text .. "\nLogging Out" gpgs.logout() end end function func\_viewUser(event) if event.phase == "ended" then debugText.text = debugText.text .. "\nGetting Acc Name" gpgs.getAccountName( getaccListener ) end end function func\_clear(event) if event.phase == "ended" then debugText.text = "" end end initText = display.newText(sceneGroup, "Init", width \* 0.7, height \* 0.05, system.nativeFont, 18) initText:addEventListener("touch", func\_init) isConnectedText = display.newText(sceneGroup, "Check Con", width \* 0.75, height \* 0.125, system.nativeFont, 18) isConnectedText:addEventListener("touch", func\_checkCon) -- loginText = display.newText(sceneGroup, "Log in no param", width \* 0.8, height \* 0.2, system.nativeFont, 18) -- loginText:addEventListener("touch", func\_login) login2Text = display.newText(sceneGroup, "Log in", width \* 0.8, height \* 0.05, system.nativeFont, 18) login2Text:addEventListener("touch", func\_login2) logoutText = display.newText(sceneGroup, "Log out", width \* 0.75, height \* 0.2, system.nativeFont, 18) logoutText:addEventListener("touch", func\_logout) getAccText = display.newText(sceneGroup, "Get Acc", width \* 0.75, height \* 0.275, system.nativeFont, 18) getAccText:addEventListener("touch", func\_viewUser) clearLogText = display.newText(sceneGroup, "Clear", width \* 0.25, height \* 0.3, system.nativeFont, 18) clearLogText:addEventListener("touch", func\_clear) -- ///////////////////////////////IAP\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ local store = require( "plugin.google.iap.v3" ) local json = require( "json" ) -- Transaction listener function function transactionListener( event ) -- newText.text = "" if not ( event.transaction.state == "failed" ) then -- Successful transaction print( json.prettify( event ) ) print( "event.transaction: " .. json.prettify( event.transaction ) ) debugText.text = debugText.text.."\nJSON:"..tostring(json.prettify(event.transaction)) else -- Unsuccessful transaction; output error details print( event.transaction.errorType ) print( event.transaction.errorString ) debugText.text = debugText.text.."\nError Type:"..tostring(event.transaction.errorType).."\nErrorString:"..tostring(event.transaction.errorString) end end function func\_initStore(event) if event.phase == "ended" then store.init( transactionListener ) debugText.text = debugText.text.."\nStore Active:"..(tostring(store.isActive)) debugText.text = debugText.text.."\nCan Load:"..(tostring(store.canLoadProducts)) end end function func\_loadProducts(event) if event.phase == "ended" then debugText.text = debugText.text.."\nLoading Products" productIdentifiers = {} table.insert(productIdentifiers, "nerdy\_pack") table.insert(productIdentifiers, "hen\_do\_pack") table.insert(productIdentifiers, "stag\_do\_pack") store.loadProducts( productIdentifiers, func\_loadProducts ) end end function func\_buyStore(event) if event.phase == "ended" then debugText.text = debugText.text.."\nPurchasing Hen Do Pack" -- store.purchase( productIdentifiers[i] ) store.purchase( "hen\_do\_pack" ) end end -- Initialize Google IAP storeInitText = display.newText(sceneGroup, "Init Store", width \* 0.2, height \* 0.05, system.nativeFont, 18) storeInitText:addEventListener("touch", func\_initStore) storeLoadProductsText = display.newText(sceneGroup, "Load Product", width \* 0.2, height \* 0.125, system.nativeFont, 18) storeLoadProductsText:addEventListener("touch", func\_loadProducts) storeBuyText = display.newText(sceneGroup, "Buy", width \* 0.2, height \* 0.2, system.nativeFont, 18) storeBuyText:addEventListener("touch", func\_buyStore)

You cannot use your developer account to test IAP. You will need to create a different email/gmail account, log in with that account (and may need to set it up in the portal as well) and make sure your device is logged in with that different email to test IAP.

Rob

Hi Rob, thank you for the response, I wasn’t aware that you are not able to use the developer account to test the IAP (seems a bit unintuitive?).

Anyway, I logged in with a different account, and am recieving ‘event.errorMessgae = sign in failed; event.errorCode = 10002’. I suspect this is what you meant by ‘may need to set it up in the portal as well’.
 

So I added my alternate account to;

"License Testing - Gmail accounts with testing access"

But I am still receiving the 10002 code - having a look on google, there was another thread on this forum that had a similar issue, but couldn’t make much sense of it - it seems “delete the app from play store, start again” was kind of where it was heading. Can you shed any additional light on this error code?

Kind Regards!

  • P.S: I just realised that the account I was originally testing this with “chester.t.garxxxx@xxxxxx.com” isn’t the same as the developer account that the developer console was set up with. The “chester.xxx” account is also added to the “gmail accounts with testing access” too. Knowing this, does that indicate an oauth issue or something similar?

Hi Rob, sorry for hassling! I wasn’t sure if you’ve seen my reply (post above this one), but I’m still facing some issues - would you be able to help?

Many thanks
Chester

As your questions. If it’s not directly related to this question, please start a new thread.

Rob

I believe it to be directly related to the question as it is a *direct* effect of the solution you provided, and have asked you to provide more information on your solution.

I have made another post regardless…

Sorry, I believe my last reply was intended for a different thread. You’re questions are on topic. Lets continue here since all the information is here. Since no one has responded on the other thread, I’ll remove it.

I’m not sure what’s going on. Helping people with what goes on inside the various vendors portals is tough because I can’t see what you’ve done. Let me research this a bit further.

Rob

Have you tried these steps?

https://productforums.google.com/forum/#!topic/play/WKGwRFUYJqg;context-place=topicsearchin/play/category$3Aandroid

Basically on your Android device, open Settings. From the settings screen select “Apps” or “Applications”. This should give you a list of installed apps. Find the “Google Play Services” app and tap on it.

Click on Storage->Clear Cache/Data. Depending on the version, it may be two different buttons.

Rob

HI Rob, thanks again!

Yeah I’ve attempted all steps provided within that link. I also created a new gmail account and attempted with that (as it is not affiliated with any developer account), but to no avail - 10002

I can provide you with access to the developer console, or provide screenshots of the console if required.

I’ve also found a reply where you suggested IAP Badger to another developer. I think I’ll try that and report back.

Regards

You can try IAP badger, but you’re still going to have to be able to login through Google Play. The link I provided above has additional steps to try including removing the Google Play app. You need to exhaust those steps. 

Can you make purchases through Google Play? What happens if you try and make an in-app purchase from another app?

Sure enough, IAP Badger results in the same issue.

I tried all steps within the link, including uninstalling GPS and letting it re-update, and removing and adding my account again.

I can purchase from the store like normal, as well as IAPs like normal, and have never faced this issue in day-to-day purchases.

Is the Monetization Guide still in the queue for updating? I’m starting to think I must have missed a console-related step

Hi Rob,

I have some more information: Reading the developer.android.com documentation regarding Testing IAPs (https://developer.android.com/google/play/billing/billing_testing.html), I must have the APK within Alpha or Beta channels, with testers assigned. I have done this, but still require the Production Channel Application to be ‘Published’ before testers can access the Alpha or Beta channels of the application. I was not aware of this, thinking that IAP testing was available from production channel, even if the application was not published.

I can only blame myself for wasting your time, my sincerest appologies!!

I will publish our application *without* the IAPs on the Production channel, upload a version *with* IAPs on the Closed Alpha channel, then I should be able to test properly.

I fully understand your prediciment of “Helping people with what goes on inside the various vendor’s portals is tough because I can’t see what you’ve done”. I’ll do what I said above, and will report back in the next day or two.

Many thanks once more,

Chester

Hi Rob,

I have now got a build published in the Production Channel, as well as a build within the Alpha Channel - The Alpha Channel has the code (above) within it.

I am now recieving a “The item you requested is not available for purchase” error, despite having items within the console to purchase .

I have added the lines;

debugText.text = debugText.text.."\n- products: "..tostring(event.products) debugText.text = debugText.text.."\n- invalid products: "..tostring(event.invalidProducts)

Which prints out ‘nil’ for both .products and .invalidProducts.

Any idea why this might be occurring?

I can make a new thread if required.

Regards

Chester

Code provided anyway;

The workflow is;

func_init -> func_checkCon -> func_login2 -> func_viewUser -> func_initStore -> func_loadProducts -> func_buyStore

 debugText = display.newText(sceneGroup, "", width \* 0.01, height \* 0.01, system.nativeFont, 10) debugText.anchorX, debugText.anchorY = 0, 0 debugText:setFillColor(0.5,0.5,0.5) local gpgs = require( "plugin.gpgs" ) function gpgsListener(event) debugText.text = debugText.text .. "\nGPGS LISTENER;\n".."E.name:"..tostring(event.name).."\nE.isError:"..tostring(event.isError).."\nE.errorMessage:"..tostring(event.errorMessage).."\nE.errorCode:"..tostring(event.errorCode) end function getaccListener(event) debugText.text = debugText.text .. "\nACC LISTENER;\n".."E.name:"..tostring(event.name).."\nE.isError:"..tostring(event.isError).."\nE.errorMessage:"..tostring(event.errorMessage).."\nE.errorCode:"..tostring(event.errorCode).."\nE.accountName"..tostring(event.accountName) end function func\_init(event) if event.phase == "ended" then debugText.text = debugText.text .. "\nAttempting to INIT" gpgs.init( gpgsListener ) end end function func\_checkCon(event) if event.phase == "ended" then connectedToGPGS = gpgs.isConnected() debugText.text = debugText.text .. "\nConnection Status:"..tostring(connectedToGPGS) end end -- function func\_login(event) -- if event.phase == "ended" then -- debugText.text = debugText.text .. "\nLogin with NO params" -- gpgs.login() -- end -- end function func\_login2(event) if event.phase == "ended" then debugText.text = debugText.text .. "\nLogin WITH params" params = { userInitiated = true, listener = gpgsListener, } gpgs.login( params ) end end function func\_logout(event) if event.phase == "ended" then debugText.text = debugText.text .. "\nLogging Out" gpgs.logout() end end function func\_viewUser(event) if event.phase == "ended" then debugText.text = debugText.text .. "\nGetting Acc Name" gpgs.getAccountName( getaccListener ) end end function func\_clear(event) if event.phase == "ended" then debugText.text = "" end end initText = display.newText(sceneGroup, "Init", width \* 0.7, height \* 0.05, system.nativeFont, 18) initText:addEventListener("touch", func\_init) isConnectedText = display.newText(sceneGroup, "Check Con", width \* 0.75, height \* 0.125, system.nativeFont, 18) isConnectedText:addEventListener("touch", func\_checkCon) -- loginText = display.newText(sceneGroup, "Log in no param", width \* 0.8, height \* 0.2, system.nativeFont, 18) -- loginText:addEventListener("touch", func\_login) login2Text = display.newText(sceneGroup, "Log in", width \* 0.8, height \* 0.05, system.nativeFont, 18) login2Text:addEventListener("touch", func\_login2) logoutText = display.newText(sceneGroup, "Log out", width \* 0.75, height \* 0.2, system.nativeFont, 18) logoutText:addEventListener("touch", func\_logout) getAccText = display.newText(sceneGroup, "Get Acc", width \* 0.75, height \* 0.275, system.nativeFont, 18) getAccText:addEventListener("touch", func\_viewUser) clearLogText = display.newText(sceneGroup, "Clear", width \* 0.25, height \* 0.3, system.nativeFont, 18) clearLogText:addEventListener("touch", func\_clear) -- ///////////////////////////////IAP\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ local store = require( "plugin.google.iap.v3" ) local json = require( "json" ) -- Transaction listener function function transactionListener( event ) -- newText.text = "" if not ( event.transaction.state == "failed" ) then -- Successful transaction print( json.prettify( event ) ) print( "event.transaction: " .. json.prettify( event.transaction ) ) debugText.text = debugText.text.."\nJSON:"..tostring(json.prettify(event.transaction)) else -- Unsuccessful transaction; output error details print( event.transaction.errorType ) print( event.transaction.errorString ) debugText.text = debugText.text.."\nError Type:"..tostring(event.transaction.errorType).."\nErrorString:"..tostring(event.transaction.errorString) end end function func\_initStore(event) if event.phase == "ended" then store.init( transactionListener ) debugText.text = debugText.text.."\nStore Active:"..(tostring(store.isActive)) debugText.text = debugText.text.."\nCan Load:"..(tostring(store.canLoadProducts)) end end function func\_loadProducts(event) if event.phase == "ended" then debugText.text = debugText.text.."\nLoading Products" productIdentifiers = {} table.insert(productIdentifiers, "nerdy\_pack") table.insert(productIdentifiers, "hen\_do\_pack") table.insert(productIdentifiers, "stag\_do\_pack") store.loadProducts( productIdentifiers, func\_loadProducts ) end end function func\_buyStore(event) if event.phase == "ended" then debugText.text = debugText.text.."\nPurchasing Hen Do Pack" -- store.purchase( productIdentifiers[i] ) store.purchase( "hen\_do\_pack" ) end end -- Initialize Google IAP storeInitText = display.newText(sceneGroup, "Init Store", width \* 0.2, height \* 0.05, system.nativeFont, 18) storeInitText:addEventListener("touch", func\_initStore) storeLoadProductsText = display.newText(sceneGroup, "Load Product", width \* 0.2, height \* 0.125, system.nativeFont, 18) storeLoadProductsText:addEventListener("touch", func\_loadProducts) storeBuyText = display.newText(sceneGroup, "Buy", width \* 0.2, height \* 0.2, system.nativeFont, 18) storeBuyText:addEventListener("touch", func\_buyStore)

You cannot use your developer account to test IAP. You will need to create a different email/gmail account, log in with that account (and may need to set it up in the portal as well) and make sure your device is logged in with that different email to test IAP.

Rob

Hi Rob, thank you for the response, I wasn’t aware that you are not able to use the developer account to test the IAP (seems a bit unintuitive?).

Anyway, I logged in with a different account, and am recieving ‘event.errorMessgae = sign in failed; event.errorCode = 10002’. I suspect this is what you meant by ‘may need to set it up in the portal as well’.
 

So I added my alternate account to;

"License Testing - Gmail accounts with testing access"

But I am still receiving the 10002 code - having a look on google, there was another thread on this forum that had a similar issue, but couldn’t make much sense of it - it seems “delete the app from play store, start again” was kind of where it was heading. Can you shed any additional light on this error code?

Kind Regards!

  • P.S: I just realised that the account I was originally testing this with “chester.t.garxxxx@xxxxxx.com” isn’t the same as the developer account that the developer console was set up with. The “chester.xxx” account is also added to the “gmail accounts with testing access” too. Knowing this, does that indicate an oauth issue or something similar?

Hi Rob, sorry for hassling! I wasn’t sure if you’ve seen my reply (post above this one), but I’m still facing some issues - would you be able to help?

Many thanks
Chester

As your questions. If it’s not directly related to this question, please start a new thread.

Rob

I believe it to be directly related to the question as it is a *direct* effect of the solution you provided, and have asked you to provide more information on your solution.

I have made another post regardless…