blowfishJ / google-safe-browsing

Automatically exported from code.google.com/p/google-safe-browsing
1 stars 0 forks source link

Open source python client doesn't send the apikey parameter on request for full-length hashes. #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello, 
It seems that this implementation doesn't send the apikey parameter on 
request for full-length hashes. The result is that on queries for 
blacklisted URLs I get an exception and 403 error ("ServerError: 
gethash failed: HTTP Error 403: Forbidden") 

Adding the apikey parameter fixed the problem for me: 

--- server.py.old       2010-05-18 14:08:24.000000000 +0100 
+++ server.py   2010-05-18 14:07:46.000000000 +0100 
@@ -285,10 +285,15 @@ 
         raise Error('All prefixes must have length: %d' % prefix_length) 
     try: 
+      apikey_param = '' 
+      if self._apikey: 
+        apikey_param = '&apikey=' + self._apikey 
+ 
       resp = self._MakeRequest( 
           Server.GETHASH, 
           postdata='%d:%d\n%s' % (prefix_length, prefix_length * len(prefixes), 
                                   ''.join(prefixes)), 
+          extra_params=apikey_param, 
           hp=(self._gethash_host, self._gethash_port)) 
     except ServerError, e: 
       orig = e.OriginalError() 

Original email thread: 
http://groups.google.com/group/google-safe-browsing-api/browse_thread/thread/ff2
ddd64b2f0db0b?
hl=en_US#

Original issue reported on code.google.com by noel...@google.com on 18 May 2010 at 7:41

GoogleCodeExporter commented 9 years ago

Original comment by noe.l...@gmail.com on 18 May 2010 at 7:42

GoogleCodeExporter commented 9 years ago
Fixed in version 0.2.

Original comment by noe.l...@gmail.com on 1 Jun 2010 at 6:44