Using the Google Play Developer API to Retrieve Reviews for your Android App

Ross Butler
Go City Engineering
7 min readJan 13, 2023
Photo by Denny Müller on Unsplash

Monitoring what users are saying about your app is key to providing a good experience and in turn, achieving a good star rating in the Google Play Store. It’s possible for Android developers to check feedback in the store on a regular basis but as a manual task, it’s easy to forget to do it. Having a reviews API allows Android developers to automate how they receive feedback — e.g. publishing reviews to a team Slack channel or adding alert triggers based on certain conditions e.g. in the event of a one-star review.

The following provides a step-by-step breakdown of how to access the Google Play Developer API in order to obtain reviews for your apps:

Note: You will only be able to retrieve reviews for apps you have developed using this method.

1) Enable API Access

The first step is to enable API access in the Google Play Console. Sign in to the console as the owner of the Google Play Developer account as only the owner is able to enable API access. From the menu on the left-hand side of the page, scroll down to and expand the Setup section of the menu. Select API access from within the Setup submenu.

You’ll be asked whether you wish to enable API access from this screen. As part of this, you’ll need to either create a new Google Cloud account or link an existing one. Follow the instructions provided to link your Google Play Developer account to a Google Cloud account.

Setup -> API Access Screen in the Google Play Console

2) Configure an OAuth2 Client ID

From the API access page above, scroll down to the section on APIs:

APIs Section of the API Access Screen

Select the button labelled “View API details”. This will take you to your linked Google Cloud account.

Google Cloud Console Menu

You will need to configure an Oauth consent screen in order to allow your Oauth client (once you have configured it below) to access your Google account.

From the left-hand menu (also shown in the screenshot), select Oauth consent screen. Configuring a consent screen is a 4-step process comprising the following steps:

  • Oauth consent screen
  • Scopes
  • Optional info
  • Summary

On the Oauth consent screen stage (first stage), you will need to complete the following fields (the rest can be left blank):

  • App name (use the app name you specified previously when creating the Oauth client ID)
  • User support email (you can use your own email address here)
  • Authorized domains (if the authorized redirect URI you are planning to use is https://www.mydomain.com/myPage then you will need to specify your domain mydomain.com here)
  • Developer contact information (you can use your own email address here as well)

On the Scopes, Optional info and Summary screens you shouldn’t need to specify any further information so click Save & Continue through each screen until you reach the end of the process.

The Oauth consent screen page should now have a section as follows:

You will need to ensure that the Publishing status is set to In production before you can use of the API so make sure that you click the button to publish here. If this page isn’t published you won’t be able to give your Oauth application access to your Google account.

We now need to configure our Oauth client ID. To do so, from the left-hand menu again, navigate to Credentials. Then from that page select Create Credentials -> OAuth Client ID.

The following screen allows you to configure the metadata for an OAuth client. From the Application type drop-down select Web application, then enter a name for your client (which can be whatever you want to name it).

You will also need to specify an authorised redirect URI. Make sure you enter your own website URL here because an authorization token (named the code parameter) will be sent to this URL later on (you wouldn’t want another website operator obtaining this information). The URL can be the front page of your own website — you don’t need to code a page specifically to read the value of the authorization token.

3) Authorize the Oauth Client

Having created an Oauth client ID, construct a URL which will allow you to grant access to your Google account to the Oauth client you just created. The Google account you use here must have access to the Google Play Console in order to access your app reviews.

In the URL below, fill in the template with:

https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=<your redirect URI>&client_id=<your client ID>

  • redirect_uri — The redirect URI you filled in when creating the Oauth client ID above (remember the domain must also have been authorized when creating the Oauth consent screen).
  • client_id — The client ID you were given following the successful creation of your Oauth client ID.

Your client ID should be of the form:

<identifier>.apps.googleusercontent.com

Now open the URL you just created in your web browser. You will be asked to login to your Google account.

*Note that instead of gocity.com the dialog should state the domain for the redirect URI you specified earlier.

On the following screen after logging in, you will be asked whether you want to allow the Oauth application you just created to access your Google account. Confirm that you wish to allow access to your newly-created application then Sign in with Google should redirect you to the URL you specified as the redirect URI when creating the Oauth client ID.

Oauth Consent Screen Configured Earlier

If the URL you specified as the redirect URI was:

https://www.mydomain.com/myPage

then you will notice that the URL you have been redirected to looks as follows:

https://www.mydomain.com/myPage?code=<code>&scope=https://www.googleapis.com/auth/androidpublisher

Copy & paste the value of the code parameter above as you will need this in order to obtain an access token to access the reviews API. It’s worth making a note of this code for future reference as you may need it should your access_token / refresh_token (obtained as part of step 4 below) expire in the future.

4) Obtain an Access Token

Using a client that allows you to make API requests such as cURL or Postman, construct an API request to:

https://accounts.google.com/o/oauth2/token

The request will need to be a POST request in order that you may specify a JSON body which should look as follows using Postman:

POST Request Configured in Postman for Obtaining an Access Token
  • code The value for the code parameter should be the value you obtained after signing into your Google account and authorising your Oauth client application.
  • client_id The value of the client id parameter should be the value you were provided with immediately after creating your Oauth client ID.
  • client_secret At the same time as receiving your client id, you should also have received a client secret.
  • redirect_uri The value of the redirect URI should be the one you specified when specifying the authorised redirect URI for your Oauth client ID e.g. https://www.mydomain.com/myPage.
  • grant_type The value of this should be authorization_code as shown above.

All being well, the JSON response you receive from the endpoint should look something like as follows:

{
"access_token": "your access token",
"expires_in": 3599,
"refresh_token": "your refresh token",
"scope": "https://www.googleapis.com/auth/androidpublisher",
"token_type": "Bearer"
}

Copy & paste the value of the access_token field as you will need this for the final step.

5) Make the Reviews API Call

All that’s left is to make the API request to:

https://androidpublisher.googleapis.com/androidpublisher/v3/applications/<bundle identifier>/reviews

Ensure that you fill in the bundle identifier for the app you want to retrieve reviews for in the above URL. You’ll need to use the Bearer Token method of authorisation to access this endpoint. This involves adding an Authorization header to your request of the form:

Authorization: Bearer <Bearer Token>

The value of the bearer token to be used above is the access_token you received in step 4 earlier.

You should be able to configure this via the Authorization tab in Postman (see screenshot).

And that’s it! 🪄

After making the final API call to the reviews API, you should receive a JSON response containing your reviews. By default, this API seems to return reviews for the current week only so you’ll likely need to call it on a weekly basis.

--

--

Ross Butler
Go City Engineering

Senior Engineering Manager @ Go City. All views are my own.