0

I am currently working on some code that connects to our Google apps domain, makes some administrative changes and then impersonates different users in our domain and uploads data to their drive, email and calendar. What I'm trying to do is figure out the proper way to use SignedJwtAssertionCredentials and change the "sub" kwarg. Do I need to redo the whole oauth process for each user I want to impersonate, i.e...

http = httplib2.Http()
credentials = SignedJwtAssertionCredentials(service_account, key, scope=api_scopes, sub=current_user)
http = credentials.authorize(http)
service = build(api_service, api_version, http=http)

or is there a way to just update/modify the sub kwarg and then re-authorize the httplib2 object?

I tried doing it the first way I described and it doesn't seem to work, about half way through the programs execution, I start getting odd errors saying,

WARNING:oauth2client.util:new_request() takes at most 1 positional argument (2 given)

Does anyone have any ideas on why I'm getting this error and or the best way I can implement the oauth process to do what I need it to?

Thanks!

LexNix
  • 377
  • 1
  • 3
  • 10
  • I cannot see a drawback in creating a new SignedJwtAssertionCredentials and Http objects (memory usage? "del" them...). If you want to reuse Http objects you can create a map email->Http – AMS Jun 13 '14 at 11:06
  • Yeah, that's exactly what I did. I created a simple map of our users to their respective http objects, yet I still get this stupid error. I wonder if there is some other problem with my code and I'm looking in the wrong area. – LexNix Jun 13 '14 at 16:14
  • May be. I do keep a dict but now that I see it, it's made of SignedJwtAssertionCredentials instances, not Http instances. I can't remember if there was a reason for that, but it could be so in order to avoid that error. – AMS Jun 16 '14 at 09:11
  • I'm starting to think it has something to do with the way I'm handling resumable MediaFileUploads. I'm noticing that this error is popping up when the program starts uploading email messages via the mail migration api. Specifically when calling the next_chunk() method. Curiouser and curiouser... – LexNix Jun 16 '14 at 21:28

0 Answers0