3

I have an old project, that is trying to retrieve data from google analytics.

It is not working, so I am trying to figure out what's wrong.

Found an example code to work with Analytics on server side.

  scope = ['https://www.googleapis.com/auth/analytics.readonly']
  key_file_location = 'secrets.json'

  credentials = ServiceAccountCredentials.from_json_keyfile_name(key_file_location, scopes=scope)
  http = credentials.authorize(httplib2.Http())
  service = build('analytics', 'v3', http=http)

  accounts = service.management().accounts().list().execute()
  print (accounts)

It is working with secrets file for my test account. But it's not working for secrets file of an old project. I recieve the following error:

oauth2client.client.HttpAccessTokenRefreshError: invalid_client: The OAuth client was not found.

What's the problem? The secrets file is out of date? If it is, am I able to recieve another one without access to the google account?

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Snobby
  • 1,067
  • 3
  • 18
  • 38

1 Answers1

4

When you registered the application on Google developer console you created some OAuth credentials.

invalid_client: The OAuth client was not found

means that the client id you are using isn't there anymore someone probably deleted it. You will need to create new credentials.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • 1
    So I have two options, as I understood. 1. Retrieve access to an account, where this Client_ID was created and create another "service account keys". 2. Create Client_ID on another account. Give permissions in Google Analytics from accounts with Analytics installed to this account. Am I wright? – Snobby Jan 10 '17 at 12:08
  • 1
    exactly however it sounds to me like who ever had access to the account that created your original client id service account keys has deleted it. I would just create a new one and add permissions for it in Google analytics (option 2) – Linda Lawton - DaImTo Jan 10 '17 at 12:19