Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to resolve 403 forbidden issue when trying to use Google Android Play API (androidpublisher.reviews.list) to get android app reviews #1688

Closed
ankitsakhareliya opened this issue Aug 9, 2019 · 8 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@ankitsakhareliya
Copy link

ankitsakhareliya commented Aug 9, 2019

When I try to get my app reviews by following Google Android Play API with owner access, it shows me an exception "You do not have permission to execute this method." every time.

  1. Google AIP explorer https://developers.google.com/apis-explorer/?hl=en_US#p/androidpublisher/v3/androidpublisher.reviews.list (Exception: https://prnt.sc/oqjbto)

  2. PHP Google-API library https://github.com/googleapis/google-api-php-client (Exception: http://prntscr.com/oqjc2g)

Please post your suggestion here, If anyone resolved that type of issue

Thank you!

@ankitsakhareliya ankitsakhareliya changed the title How to resolve 403 forbidden issue when trying to use androidpublisher.reviews.list Google Android Play API to get android app reviews How to resolve 403 forbidden issue when trying to use Google Android Play API (androidpublisher.reviews.list) to get android app reviews Aug 9, 2019
@jdpedrie
Copy link
Contributor

jdpedrie commented Aug 9, 2019

Please share a code sample demonstrating the issue (with identifying information redacted) and authentication scopes used.

@jdpedrie jdpedrie added the type: question Request for information or clarification. Not an issue. label Aug 9, 2019
@ankitsakhareliya
Copy link
Author

Hello @jdpedrie

Thank you for your reply!

I have attached code with both method like "Auth with access token (AuthWithAccessToken.php)" and "Auth with private key (AuthWithPrivateKey.php)"

scope I used for get app review : https://www.googleapis.com/auth/androidpublisher

Description:
AuthWithAccessToken.php

  • in this file user have to auth with google first then i used "Google_Service_AndroidPublisher" method for get app review.

AuthWithPrivateKey.php

  • In this file i created new "Service account keys" and downloaded "client.json" on console google and then i configure json file in library then i used "Google_Service_AndroidPublisher" method for get app review.

I used both method and try to get app reviews but every time it returns :
{
error: {
errors: [
{
domain: "global",
reason: "forbidden",
message: "Forbidden"
}
],
code: 403,
message: "Forbidden"
}
}

code.zip

@jdpedrie
Copy link
Contributor

Are you able to access the reviews using a manually-generated access token?

Try it, it'll show us whether the issue is in your auth flow or further downstream.

  1. Visit the OAuth 2.0 Playground.
  2. Enter the scope you need at the bottom (https://www.googleapis.com/auth/androidpublisher).
  3. Walk through the auth flow and click the "Exchange authorization code for tokens" button, then copy the access token.

Execute the following code, replacing the dummy access token with the token you generated:

<?php
  require_once __DIR__ . '/vendor/autoload.php';
  session_start();
  date_default_timezone_set('America/Los_Angeles');
    
  $SCOPES = array(
  	  'https://www.googleapis.com/auth/androidpublisher',
  );
  
  $client = new Google_Client();
  $client->setScopes($SCOPES);

  // Put your access token here.
  $client->setAccessToken('ACCESS TOKEN');
  
try {
	$review = new Google_Service_AndroidPublisher($client);

	$opt_param = array();
	$reviews = $review->reviews->listReviews('PackageName', $opt_param);
}
catch (exception $e) {
	echo '<pre>';
	print_r($e->getMessage());
	exit;
}

@ankitsakhareliya
Copy link
Author

Hello @jdpedrie
Thanks for reply!

I followed what you suggest and generate access token on OAuth 2.0 Playground and copy token and set in my code but have same error occur.

Steps screenshots:
Step 1 : http://prntscr.com/orw9j8
Step 2 : http://prntscr.com/orw9u7
Step 3 : http://prntscr.com/orwaf6
Step 4 : http://prntscr.com/orwbj5
Step 5 : http://prntscr.com/orwdng
Step 6 : http://prntscr.com/orwc1h
Step 7 : http://prntscr.com/orwii0

Thanks

@myboopathiraja
Copy link

myboopathiraja commented Nov 6, 2019

HI..make sure ,you have updated the billing information ,if you have created GCP project.
if not it wont allow to process anything though it is not intimating at prior stages.

@tmatsuo
Copy link

tmatsuo commented Dec 5, 2019

@ankitsakhareliya Did you get a chance to follow the advise made by @myboopathiraja ?

@yokochi
Copy link

yokochi commented Dec 21, 2019

I think there is a mistake in how to create an service account.
see below link
https://developers.google.com/android-publisher/getting_started#using_a_service_account

https://play.google.com/apps/publish/#ApiAccessPlace
Click Grant Access to provide the service account the necessary rights to perform actions.

For your reference.

@fhinkel fhinkel self-assigned this Dec 8, 2020
@fhinkel
Copy link

fhinkel commented Dec 8, 2020

Greetings, we're closing this. Looks like the issue got resolved. Please let us know if the issue needs to be reopened.

@fhinkel fhinkel closed this as completed Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

6 participants