rmmh / skybot

Python IRC bot
https://github.com/rmmh/skybot/wiki
The Unlicense
249 stars 170 forks source link

Google API issues. #152

Open ghost opened 8 years ago

ghost commented 8 years ago

When using a browser/website API key, I get error 403 forbidden.

When using a server API key, I get error 403 forbidden.

Unhandled exception in thread started by <function run at 0x6f8699a9baa0>
Traceback (most recent call last):
  File "core/main.py", line 78, in run
    out = func(input.inp, **kw)
  File "plugins/youtube.py", line 76, in youtube
    j = http.get_json(search_api_url, **params)
  File "plugins/util/http.py", line 42, in get_json
    return json.loads(get(*args, **kwargs))
  File "plugins/util/http.py", line 30, in get
    return open(*args, **kwargs).read()
  File "plugins/util/http.py", line 84, in open
    return opener.open(request)
  File "/usr/lib/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden

How exactly do you set up the google plugin? I'm getting my api keys from here: https://console.developers.google.com/apis/credentials

Thanks :)

andyeff commented 8 years ago

Hi there, @injuntony I made a randomised config that you could use for reference: https://gist.github.com/andyeff/05553ec8795067794e09

Single API keys are a straight forward "name": "key" mapping, whereas something like twitter which needs a few different things, has a nested set inside.

@doublebirdstrike The google plugin should have a @hook.api_key('google') line in it (or two, maybe) - that means it will read whatever key is in the config file named by "google" (check my example above). Once you have the key in the config file, the plugin should be able to read it OK without any other changes.

Hopefully this helps!