7

Admin Settings API with oauth2

I'm trying to connect an app written in python to Admin Settings API with OAuth2 credentials but I get an error:

source code:

from oauth2client.client import Credentials
import gdata.apps.adminsettings.service
import gdata.gauth

#credentials_json is a string with an oauth2 credential that is saved in datastore
#domain_name is the name of the target domain
#app_name is my application name

credentials = Credentials.new_from_json(credentials_json)
auth2token = gdata.gauth.OAuth2TokenFromCredentials(credentials)
service = gdata.apps.adminsettings.service.AdminSettingsService(source=app_name,domain=domain_name)
service = auth2token.authorize(service)

print service.GetMaximumNumberOfUsers()

exception:

Traceback (most recent call last):
  File "<input>", line 25, in <module>
  File "xxxxxxx\lib\gdata\apps\adminsettings\service.py", line 116, in GetMaximumNumberOfUsers
    result = self.genericGet('general/maximumNumberOfUsers')
  File "xxxxxxx\lib\gdata\apps\adminsettings\service.py", line 50, in genericGet
    return self._GetProperties(uri)
  File "xxxxxxx\lib\gdata\apps\service.py", line 522, in _GetProperties
    str(self.Get(uri))))
  File "xxxxxxx\lib\gdata\service.py", line 1069, in Get
    headers=extra_headers)
  File "xxxxxxx\lib\atom\__init__.py", line 93, in optional_warn_function
    return f(*args, **kwargs)
  File "xxxxxxx\lib\atom\service.py", line 186, in request
    data=data, headers=all_headers)
  File "xxxxxxx\lib\atom\http_interface.py", line 148, in perform_request
    return http_client.request(operation, url, data=data, headers=headers)
TypeError: new_request() takes exactly 1 argument (4 given)

thank you very much for your attention

Carlos Prieto

cprietorod
  • 211
  • 1
  • 7
  • 1
    hey cprietorodriguez, I have the same problem with requests when using oauth2 with gdata. Could you please let me know how you managed to fix the problem ? – Meriam-K Oct 27 '14 at 13:17

1 Answers1

0

From AdminSettings API using service account auth/keyword failures it seems like the gdata service objects don't support Oauth 2.0 I had a similar error using the gdata contacts service object, an fixed it by using the contacts client object instead. The admin settings apps doesn't appear to have a client, just a service but the linked stackoverflow page has a workaround.

Community
  • 1
  • 1
Quellan
  • 1
  • 1