invalid_client: The OAuth client was not found. Python

Question:

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?

Asked By: Snobby

||

Answers:

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.

Answered By: DaImTo