Search code examples
androidsubscriptiongoogle-play-developer-api

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?


Solution

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