googleapis / google-api-python-client

🐍 The official Python client library for Google's discovery based APIs.
https://googleapis.github.io/google-api-python-client/docs/
Apache License 2.0
7.77k stars 2.41k forks source link

Connecting to Google Search Console API #2049

Open AmericanY opened 1 year ago

AmericanY commented 1 year ago

Basically, Someone already added my email to Google Search Console and right now i can see the site listed under the search console from the browser.

Now, Am trying to connect to Google Search Console API.

I already enable Google Search Console API and created a service account.

Currently, am trying to list the sites within the API but it's giving an empty dictionary! not sure what am missing here?

from googleapiclient._auth import credentials_from_file
from googleapiclient.discovery import build

service = build('searchconsole', 'v1', credentials=credentials_from_file(
    'credentials.json'))
print(service.sites().list().execute())

output:

{}
parthea commented 1 year ago

Hi @AmericanY,

Please could you try out a similar request in the 'Try this method' interface on this page and check whether the issue still exists? This helps to confirm if this is a client library issue or a API issue. If it is an API issue, we'll redirect you to the API support channel so you can get better quality answers. For the Search Console API please see https://developers.google.com/search/help.