Question

I'm trying to figure out what the http parameter is in this function

https://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.client-module.html#verify_id_token

I'm doing http=None and it's working fine but am I supposed to put something else in there? I don't understand what this means:

http: httplib2.Http, instance to use to make the HTTP request. Callers should supply an instance that has caching enabled.

It would be great to see a code sample showing how this is used.

Was it helpful?

Solution

The documentation that you linked to has the answer:

http: httplib2.Http, instance to use to make the HTTP request. Callers should supply an instance that has caching enabled.

So, if you want to configure an Http instance with custom arguments instead of the defaults—like enabling caching, as the docs suggest—you construct it, and then pass it here.

The other advantage of passing in a custom Http instance is that you can use a single instance for multiple calls—which makes caching, cookies, etc. a lot more useful.

See httplib2 for how to do this. Note that there's a link to a list of detailed examples, as well as to the docs. Most likely, those examples will be much more useful to you than anything anyone slaps together to post on Stack Overflow. The very first example shows you, in one line, how to create an Http instance with basic caching. Two examples down, it shows how to use cache-control. And so on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top