pythongoogle-analyticsgoogle-api-python-clientservice-accountsoauth2client

Google Analytics Embed API Service Account Access Token


https://ga-dev-tools.appspot.com/embed-api/server-side-authorization/

I have created a Google service account in anticipation of using the Google Analytics Embed API and have been provided a .json key file. I am now attempting to execute the above Google instructions to install Google's Python API Client. The google-api-python-client Python module is being installed properly, however when I attempt to execute the provided Python code to obtain the access token I get the following message:

from oauth2client.service_account import ServiceAccountCredentials
ImportError: No module named oauth2client.service_account

I have wasted hours trying to resolve this. Any assistance would be greatly appreciated.

I am using Mac OS High Sierra.


Solution

  • I got briefly stuck on this recently too. While their documentation tells you to install the google-api-python-client via pip just fine, you still need to install the oauth2client too if you haven't already (which it seems you haven't).

    You can do that like this:

    pip install --upgrade oauth2client

    Then try again and it should work for you!