4

I want to use Purchases.subscriptions:get. in my django server

My Google API's project is linked my android application.

And i used service account(json) of Google API, service account's permission is project's owner and google play console's admin.

This is my code

from oauth2client.service_account import ServiceAccountCredentials
from httplib2 import Http
from googleapiclient.discovery import build

scopes = ['https://www.googleapis.com/auth/androidpublisher']

credentials = ServiceAccountCredentials.from_json_keyfile_name('service_account.json', scopes)

http_auth = credentials.authorize(Http())

androidpublisher = build('androidpublisher', 'v3', http=http_auth)
product = androidpublisher.purchases().products().get(productId="", packageName="", token="")

purchase = product.execute()

This is response.

The current user has insufficient permissions to perform the requested operation

What's wrong????

HEE JAE CHOI
  • 85
  • 2
  • 5

1 Answers1

3

Possibility 1

Possibly your service account doesn't have the required permissions? This is what the error message says.

In the Play Console, click on

  • Settings
  • Users and Permissions

Look for your service account. Check that it has all the needed permissions to get Purchase information (probably needs read financial data permission)

Possibility 2

You seem to be passing an empty package name, productId, and token in, Have you tried setting these correctly?

Nick Fortescue
  • 13,530
  • 1
  • 31
  • 37
  • 1
    Thanks, checking and fixing permissions under "Users and Permissions" solved my problem! What I also noticed is that the modification needs time (~15-30 mins) to take effect. – gabhor Feb 26 '19 at 07:22
  • @GáborHorváth I was banging my head against the wall trying to figure out why this was not working until I came across this post. Where is the documentation for this? I hate Android – Constantine Apr 28 '19 at 23:59