Moh
Moh

Reputation: 2087

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

Upvotes: 0

Views: 1682

Answers (2)

ali soleimanidehdivan
ali soleimanidehdivan

Reputation: 81

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

Upvotes: 4

Hasan Ramezani
Hasan Ramezani

Reputation: 5194

The problem is because Google API want to access the location that not permission to it.

Run your script by super user. something like this:

sudo python test.py

If you know the location that Google API want to access, change the permission of location by chmod command.

Upvotes: 2

Related Questions