Reputation: 315
I am having trouble calling the Google Play Developer API.
I have followed all steps listed on https://developers.google.com/android-publisher/authorization . This includes
Then, to call the purchases.subscriptions.get API, I used the following CURL command:
(https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions/get)
curl -X GET "https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token}" -H "Authorization: Bearer {access_token}" -H "Accept: application/json" --compressed
However, I am receiving the following error:
"error": {
"code": 401,
"message": "The current user has insufficient permissions to perform the requested operation.",
"errors": [
{
"domain": "androidpublisher",
"message": "The current user has insufficient permissions to perform the requested operation.",
"reason": "permissionDenied"
}
]
}
}
I have read and implemented changes recommended in other posts such as
I have also tried calling the API through https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions/get#authorization-scopes but still no luck (get an error).
If anyone has any suggestions, that would be very much appreciated. Thanks.
Upvotes: 15
Views: 12441
Reputation: 161
In 2024 I think the options in Google play console got changed. In My case it worked after adding the service account email in "Users and permissions" section of Google Play Console.
Important note: that we need to wait at-least 24hrs after adding the user in Google play console
Upvotes: 4
Reputation: 41
In case someone else runs into this issue. If your app is still in testing don't forget to add the service account to your testers.
Upvotes: 4
Reputation: 147
30 hours later, I found what was wrong with mine, I didn't click the Add app button on the Users and Permissions page after adding the service account.
Upvotes: 5
Reputation: 647
I encountered the same issue. In my case, I was not using a key file (json one) for the granted service account on Google Play while verifying purchases on the back-end. I replaced the wrong key file with the one of granted service account on Google Play and it's working fine now.
Upvotes: 0
Reputation: 4040
I faced a similar issue, the problem is in the settings we do in google developer project.
Refer to create-play-service-credentials for settings. Use the same primary account with which you created your in-app products.
Make sure you remove the previous one.
Link to a Google Developer Project Your Play Developer account needs to be linked to a Google Developer Project.
1a. Open the Settings > Developer account menus and select API access
1b. Select Link to connect your Play account to a Google Developer Project
1c. Agree to the terms and conditions
2. Create Service Account Next we need to create a service account. This is done from the Google API Console.
2a. Select Create Service Account
2b. Create Service account key credentials
2c. Enter details for service account
2d. Download your JSON credential:
3. Grant Access
3a. In Play Console, select Grant Access on the newly created service account
3b. Grant the following permissions:
3c.Click Invite User at the bottom and send the invite
You will be redirected to Users and Permissions where you should see your newly created service account as Active.
Upvotes: 10