title: How to Perform Authentication for validating Google In App Subscription
body: <p>I want to validate user subscription from <code>androidpublisher</code> API in server side. We have one month subscription for a product in our App. The cycle which we are following is below</p>
  
  <ul>
  <li>User will get product list. If he has subscribed, he will get full list of products. Otherwise he will get only free products.</li>
  <li>When user will subscribe, he will get a receipt from google for that purchase. That receipt will be saved in our database. Whenever user will demand list of products, that receipt will be validated from Google API. If it is valid, he will get full result. Otherwise partial.</li>
  </ul>
  
  <p>Google has given below API for this purpose.</p>
  
  <blockquote>
    <p>GET <a href="https://www.googleapis.com/androidpublisher/v2/applications/" rel="nofollow noreferrer">https://www.googleapis.com/androidpublisher/v2/applications/</a>{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}</p>
  </blockquote>
  
  <p>This Api requires authorization. I tried below code for this</p>
  
  <pre><code>receipt_json = json.loads(subscription_object.receipt)
  service = build(serviceName='androidpublisher', version='v2', developerKey='key')
  response = service.purchases().subscriptions().get(
          packageName=receipt_json.get('packageName'),
          subscriptionId=receipt_json.get('productId'),
          token=receipt_json.get('purchaseToken'))
  </code></pre>
  
  <p>But I got below response</p>
  
  <pre><code>{
   "error": {
    "errors": [
     {
      "domain": "global",
      "reason": "required",
      "message": "Login Required",
      "locationType": "header",
      "location": "Authorization"
     }
    ],
    "code": 401,
    "message": "Login Required"
   }
  }
  </code></pre>
  
  <p>Please guide me how should I perform authorization before validating receipt. One importent point, I want to validate receipt in server side. Not client side. So user will not see or click any link in order to authorize this request.</p>