0

I've worked out how OAuth2 works (via https://developers.google.com/api-client-library/python/guide/aaa_oauth) and now have an OAuth2Credentials object (let's call the object credentials) that I want to use for Google Apps provisioning purposes (the example here is using sites, but could be any of the gdata apis)

If I try:

client = gdata.sites.client.SitesClient(site="test-site",domain='my.domain')
client = credentials.authorize(client)

I get

TypeError: new_request() got an unexpected keyword argument 'http_request'

when I try to do anything

If I try

client = gdata.sites.client.SitesClient(site="test-site",domain='my.domain', auth_token=credentials)

or

client = gdata.sites.client.SitesClient(site="test-site",domain='my.domain', auth_token=credentials.access_token)

I get an AttributeError that the relevant object (credentials or credentials.access_token) has no attribute 'modify_request'

Any ideas what I can try?

askvictor
  • 3,621
  • 4
  • 32
  • 45

2 Answers2

0

I'm not entirely sure about Google's client code, but you could always try (shameless plug) sanction. It's an OAuth 2.0 client I wrote a while ago available on Github and PyPI.

The upsides:

  • Being a whopping 55 LOC, it's tremendously easy to grok. If something goes wrong, you won't have to ask questions here.. You should be able to just understand what's going on ;)
  • It has been tested with 8 different providers (including Google)

The downsides:

  • Obviously would require a refactor of your current code
  • Doesn't assume (and therefore provide) persistence implementations
  • Doesn't provide API implementations (you have to have a basic understanding of the OAuth 2.0-exposed API that you're dealing with)
Demian Brecht
  • 21,135
  • 5
  • 42
  • 46
0

This answer says you have to monkeypatch the OAuth2Credentials object, before passing it to the SitesClient(auth_token=credentials). It has an answer showing you how to do the monkey patching

Community
  • 1
  • 1
Dominic Mitchell
  • 11,861
  • 4
  • 29
  • 30
  • Saw that, but seems messy, and no supplied code. So I figured I'd see if there were a Proper Way to do it – askvictor Oct 09 '12 at 08:02