I am working on a project where we want to collect GMB performance data through the GMB API. This entails capturing many report results. We do not create or update any records for this account. However, I tried the Oauth2 approach, which required me to grant permission, and since we are not accessing or updating any user data, I would like to avoid Oauth.
From the documentation and for this use case, I believe that a service account is the best approach and I created these credentials in the Google API console.
I can create credentials, however, when I start the process, I get the following error:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://mybusiness.googleapis.com/$discovery/rest?version=v3 returned "The request is missing a valid API key.">
This seems odd since I have a valid set of service account credentials. I have included a valid API key from the Google API console, but I am getting the same error.
Here is my Python code:
import os import httplib2 import json import argparse import apiclient.discovery from oauth2client.service_account import ServiceAccountCredentials from apiclient.discovery import build api_name = 'mybusiness' api_version = 'v3' api_key = '<my valid api key from google api console that has permission for this GMB project>' discovery_uri = 'https://mybusiness.googleapis.com/$discovery/rest?version={}'.format(api_version) flow_scope='https://www.googleapis.com/auth/plus.business.manage' credentials_file = '/Google_My_Business-service_account.json'
The error is displayed from the last line. Any help is appreciated.
python google-oauth google-my-business-api
analyticsPierce
source share