Search code examples
pythongoogle-apigoogle-custom-searchapi-keygoogle-api-python-client

Unable to instantiate Google API Service: Permission Denied


I made a project in my Google account. Then authorized and access to Google Custom Search with an API Key and an ID to a Custom Search Engine. I tried to perform a search using the Python interface, by modifying the sample code. Every time I run the code after this line I get this error:

service = build("customsearch", "v1",
        developerKey="AIxx")

IOError: [Errno 13] Permission denied

I tried to create a request myself to check if the problem is with Google or me. Here is my request:

https://www.googleapis.com/customsearch/v1?q=olive+garden&cx=00026xx&key=AIxx

And it worked! So, now I'm completely confused, and cannot figure out what the problem is.

It's even more strange because when I try to perform the same search using Google APIs explorer, it returns: Daily Limit Exceeded


Solution

  • the problem is because httplib2 installer don't set read permission for others on cacerts.txt you must add read permission to others too :D

    sudo chmod o+r /Library/Python/2.7/site-packages/httplib2-0.9.2-py2.7.egg/httplib2/cacerts.txt
    

    actually httplib2 must read this from system wide certificates and i don't know why they don't. is there anybody that know why? there is patches for this specific problem like this patch for example https://bugs.mageia.org/show_bug.cgi?id=6568