Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Android publisher API responds with "410 purchaseTokenNoLongerValid" error

On getting a subscription status (https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/get) API responds with

{
  "error": {  
    "errors": [   
      {    
        "domain": "androidpublisher",    
        "reason": "purchaseTokenNoLongerValid",    
        "message": "The purchase token is no longer valid."   
      }  
    ],  
    "code": 410,  
    "message": "The purchase token is no longer valid." 
  }
}

I couldn't find any mention of "purchaseTokenNoLongerValid" or "The purchase token is no longer valid" in context of Android publisher API, neither in docs nor in Google search.

I can guess what this error means, but better to know exactly, and anyway, what should I do with the subscription after this error?

like image 853
ksimka Avatar asked Aug 15 '17 07:08

ksimka


3 Answers

I received this message recently from the Google Play team, so HTTP status 410 will be the default response for subscriptions expired for more than 60 days.

Starting on May 21, 2018, Purchases.subscriptions.get will return HTTP status 410 with no content in the response for subscriptions that have been expired for 60 days or more. There is no change for active subscriptions or canceled subscriptions that have not yet expired or been expired for fewer than 60 days.

Visit the Android developers website for more information on how to verify purchases.

And indeed, I tried it at May 22 and got a response with status 410 and this body:

{
    "error": {
        "errors": [
            {
                "domain": "androidpublisher",
                "reason": "subscriptionPurchaseNoLongerAvailable",
                "message": "The subscription purchase is no longer available for query because it has been expired for too long."
            }
        ],
        "code": 410,
        "message": "The subscription purchase is no longer available for query because it has been expired for too long."
    }
}
like image 80
zafeiris.m Avatar answered Nov 16 '22 05:11

zafeiris.m


I got an official response from Google Play support team about this error:

I took a look and the order ID you provided is associated with an account that has now been deleted. This is why it does not pass verification. This is a good example of the licensing system working as intended.

You may feel free to simply ignore this subscription.

And another email after I ask for more details:

Technically, the subscription is still active even though it's not attached to an account - hence, it does not show as cancelled. We're aware it's confusing not to receive a clear message about the account's status and just get an error back, though. This is an area of our product we're still actively working on.

What you can do is use the API to revoke the subscription, which is fine to do now that you have confirmation that the account is gone. Then it will read as cancelled and will no longer throw an error when making an API call.

like image 29
guillaume-tgl Avatar answered Nov 16 '22 05:11

guillaume-tgl


I think Google just had updated their API, and start to response with status code 410 to requests with purchase token which is not renewed a long time (no subscription renew). So they sure at 100% that subscription with such token will not be renewed.

So, it's a good news, because now you able detect such purchase tokens, and do not send them to validation at all, if you did it before.

like image 1
Stafox Avatar answered Nov 16 '22 05:11

Stafox