我想利用gdata.apps.audit.service.AuditService创建邮箱导出请求(特别是通过createMailboxExportRequest)。是否可以通过oauth或其他方式访问此api身份验证?我尽量避免要求用户提供用户名和密码。
下面是一段示例代码:
audit_service = gdata.apps.audit.service.AuditService(domain="test.com")
#would like to not use ClientLogin
client = audit_service.ClientLogin("adm_user@test.com", "superSecretPassword") # <------
audit_service.createMailboxExportRequest(user="target_user", begin_date=None, end_date=None, include_deleted=True, search_query=None)
audit_service.getAllMailboxExportRequestsStatus()
我成功地将oauth2/client_secrets用于其他管理/审计API,但我不知道如何在没有ClientLogin的情况下获得createMailboxExportRequest。如有任何帮助,我们将不胜感激。
我发现将OAuth 2.0破解到旧的GData API中最简单的方法是构建GData服务(但不授权它),然后像为新的OAuth 2.0discovery Google API那样构建凭据服务,然后在GData服务上添加适当的凭据作为头:
audit_service = gdata.apps.audit.service.AuditService(domain="test.com")
... # build your credentials like normal with oauth2client
auth_headers = {u'Authorization': u'Bearer %s' % credentials.access_token}
audit_service.additional_headers = auth_headers