AdminSettings API using service account auth/keyword failures

后端 未结 1 1699
我寻月下人不归
我寻月下人不归 2021-01-26 09:21

Trying to retreive domain number of users, \'GetCurrentNumberOfUsers()\', using AdminSettings API via a Service Account in Python. Enabled delegation wide autho

相关标签:
1条回答
  • 2021-01-26 09:59

    The old GData Python library service objects don't actually support OAuth 2.0 which is what you need to be using. However you can hack a access token on there. Try something like:

    credentials = SignedJwtAssertionCredentials(SERVICE_ACCOUNT_EMAIL, key, scope='https://apps-apis.google.com/a/feeds/domain/', sub='admin@xxxtestmail.edu')
    credentials.refresh(httplib2.Http())
    service = gdata.apps.adminsettings.service.AdminSettingsService(source="testApp", domain='xxxtestmail.edu')
    service.additional_headers[u'Authorization'] = u'Bearer {0}'.format(credentials.access_token)
    
    print service.GetCurrentNumberOfUsers()
    
    0 讨论(0)
提交回复
热议问题