Google My Business API to Obtain Location Reviews & Action on Reviews.

  • How to get My Business API Access from google.
  • Setup/Create OAuth 2.0 credentials.
  • Get Authorization Code & Access token from Google OAuth 2.0 playground.
  • Get account/locations associated with My Business API.
  • Get access token in python.
  • List Reviews, Add/Update comment on the review, Delete Reviews.
  • Go to OAuth 2.0 Playground
  • Click the gear icon to open the configuration options and make the following changes:
-> Set OAuth flow to Client-side.
-> Select Use your own OAuth credentials.
-> Paste in your OAuth client ID.
-> Close the configuration options.
  • Under “Step 1 — Select & authorize APIs,” paste the following scope for the Google My Business API into the Input your own scopes field:
  • Click Authorize APIs.
  • Click Accept when prompted.
  • Under “Step 2 — Configure request to API,” paste the following URI into the Request URI field:
  • Take the accountId from the response.
  • Install Libraries & Download client_secrets.json.
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlibDownload json:
  • Copy below code in order to get an access token using google built-in python Installed App Flow and local server.
from __future__ import print_function
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials

# If modifying these scopes, delete the file token.json.
SCOPES = ['']
CLIENT_SECRETS_FILE = 'client_secrets.json'
def main():

creds = None
# The file token.json stores the user's access and refresh tokens, and is created automatically when the authorization flow completes for the first time.

if os.path.exists('token.json'):
creds = Credentials.from_authorized_user_file('token.json', SCOPES)
#If there are no (valid)credentials available,let the user logIn.if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
flow = InstalledAppFlow.from_client_secrets_file(
creds = flow.run_local_server(port=0, ,access_type='offline', prompt='consent')
# Save the credentials for the next run
with open('token.json', 'w') as token:

if __name__ == '__main__':
  • List Reviews of Locations:
  • Get Reviews using ReviewId:
  • Reply to a review:

comment: "Thank you for visiting our business!"
  • Delete a Review






BA at Ayu Health

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Guru Maps now supports GeoJSON and MapCSS 🚀

How to Deploy Python Scrapy Spiders for Free on Cloud


All You Need to Know About Databases

Sending Push Notifications To Xamarin.Forms App

Symfony Messenger is here, but your project is on Symfony 3.4, no problem! (part 1)

Remo Milestone 2 Plan

How To Rotate Proxies in Python

AWS Cloud Practitioner Exam

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ankur Kumar

Ankur Kumar

BA at Ayu Health

More from Medium

Python - Advantages and Disadvantages

An Introduction to the Linked List Data Structure

Data Structures In Python

What happens when you type gcc main.c ?