I want to start working with the Youtube Data API by calling simple search list calls on a local server via the Python implementation. I am only reading data and I want to use the API KEY only to avoid any pop-ups etc.The sample codes and tutorials usually go with oAuth but it is my understanding that I can go with API KEY only, as long as it is not personal data I am getting.I have a registered, unrestricted API KEY. The calls work using URLs in the browser. But even a simple python code remains stuck in the execution of the call and I receive a timeout without any response from the server, not a "request denied" though.
Are you able to point me into the right direction to solve this hurdle. The code is:
import osimport googleapiclient.discoveryimport googleapiclient.errorsos.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"api_service_name = "youtube"api_version = "v3"youtube = googleapiclient.discovery.build( api_service_name, api_version, developerKey='my-api-key')request = youtube.search().list( part="snippet")response = request.execute()#Never gets past this line
I added os.environ["GOOGLE_APPLICATION_CREDENTIALS"] as was suggested somewhere with a service account file. I played around with different scopes. I used different searches, like channel or video.I would like to avoid using classic GET and call the URL as used in the browser.
A few posts with issues revolving the API KEY are out there but they typically point at the code I have used above.
UPDATE:I went through is during the night. Without changing anything, the function worked as expected the next morning. Now in the next night, again the connection issues arise. Is this possibly google disabling the API access during a certain timeframe? I have no network issues otherwise and hence not sure what else could be causing it.