HTTP Error 400 Bad Request (Other similar questions aren't helping me)
<p>None of the other similarly names questions have solved my problem.</p>

<p>Why am I getting this error? I copied and pasted this example code from google's github.</p>

<pre><code>import pprint

from googleapiclient.discovery import build

def main():
  # Build a service object for interacting with the API. Visit
  # the Google APIs Console &lt;http://code.google.com/apis/console&gt;
  # to get an API key for your own application.
  service = build("customsearch", "v1",
        developerKey="AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0")

  res = service.cse().list(
      q='lectures',
      cx='017576662512468239146:omuauf_lfve',
    ).execute()
  pprint.pprint(res)

if __name__ == '__main__':
    main()
</code></pre>

<p><a href="https://github.com/google/google-api-python-client/blob/master/samples/customsearch/main.py" rel="nofollow">Here is where I go the code from</a></p>

<p>I am getting this error :</p>

<pre><code>Traceback (most recent call last):
  File "testpython", line 17, in &lt;module&gt;
    main()
  File "testpython", line 12, in main
    cx='017576662512468239146:omuauf_lfve',
  File "/home/mddrill/.local/lib/python2.7/site-packages/oauth2client/util.py", line 137, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/mddrill/.local/lib/python2.7/site-packages/googleapiclient/http.py", line 838, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: &lt;HttpError 400 when requesting https://www.googleapis.com/customsearch/v1?q=lectures&amp;alt=json&amp;cx=017576662512468239146%3Aomuauf_lfve&amp;key=AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0 returned "Bad Request"&gt;
</code></pre>

<p>I tried to access that <a href="https://www.googleapis.com/customsearch/v1?q=lectures&amp;alt=json&amp;cx=017576662512468239146%3Aomuauf_lfve&amp;key=AIzaSyDRRpR3GS1F1_jKNNM9HCNd2wJQyPG3oN0" rel="nofollow">bad URL</a> and is says that the reason is "keyExpired". Also the code you put here includes the following documentation: </p>

<blockquote>
  <p>Visit the Google APIs Console <a href="http://code.google.com/apis/console" rel="nofollow">http://code.google.com/apis/console</a> to
  get an API key for your own application.</p>
</blockquote>

<p>Try doing as it says. Good luck!</p>

python google-api google-api-python-client