使用Admin SDK Google Workspace咨询聊天报告

发布于 2025-01-24 21:31:02 字数 2178 浏览 4 评论 0原文

我是与API SDK Google集成的新手,我需要食用有关使用Google聊天的工作区活动报告,我配置了以下代码,但我相信这是错误的,我没有找到可以帮助您的文档我要验证形式的正确方法来拨打报告API,

from oauth2client.service_account import ServiceAccountCredentials
from httplib2 import Http
from apiclient.discovery import build
import googleapiclient.discovery


#escopos necessarios
scopes = [
'https://www.googleapis.com/auth/admin.reports.usage.readonly',
'https://www.googleapis.com/auth/drive.metadata.readonly',
'https://www.googleapis.com/auth/admin.reports.usage.readonly',
'https://www.googleapis.com/auth/admin.reports.audit.readonly',
'https://www.googleapis.com/auth/analytics',
'https://www.googleapis.com/auth/analytics.readonly',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/apps.alerts',
'https://www.googleapis.com/auth/apps.order.readonly',
'https://www.googleapis.com/auth/apps.order',
'https://www.googleapis.com/auth/admin.directory.user.readonly',
'https://www.googleapis.com/auth/admin.directory.domain',
'https://www.googleapis.com/auth/admin.directory.domain.readonly',
'https://www.googleapis.com/auth/calendar.readonly' ,
'https://www.googleapis.com/auth/drive.readonly',
'https://www.googleapis.com/auth/admin.directory.user',
'https://www.googleapis.com/auth/cloud-platform'      
 
 ]
#dominio que sera pesquisado 
TARGET='dominio.test.com'

#credenciais de acesso 
credentials = ServiceAccountCredentials.from_json_keyfile_name('./chave.json', scopes)
delegated_credentials = credentials.create_delegated('[email protected]')


http_auth = credentials.authorize(Http())

service = googleapiclient.discovery.build('admin', 'directory_v1', 
credentials=delegated_credentials)

response = service.activities().list(users='all',applicationName='chat')

print(response)

我已经在其他查询中使用了此代码,并且正在访问目录和列出用户,但是当我尝试调整它以查询聊天活动时,它无效我有以下错误

    response = service.activities().list(customerId='all',applicationName='chat')
    AttributeError: 'Resource' object has no attribute 'activities'

I'm new to integrations with the API SDK GOOGLE, and I need to consume the Workspace activity reports regarding the use of google Chat, I configured the following code, but I believe it is wrong, I didn't find a documentation that helps me to validate the form correct way to make calls to the reports api

from oauth2client.service_account import ServiceAccountCredentials
from httplib2 import Http
from apiclient.discovery import build
import googleapiclient.discovery


#escopos necessarios
scopes = [
'https://www.googleapis.com/auth/admin.reports.usage.readonly',
'https://www.googleapis.com/auth/drive.metadata.readonly',
'https://www.googleapis.com/auth/admin.reports.usage.readonly',
'https://www.googleapis.com/auth/admin.reports.audit.readonly',
'https://www.googleapis.com/auth/analytics',
'https://www.googleapis.com/auth/analytics.readonly',
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/apps.alerts',
'https://www.googleapis.com/auth/apps.order.readonly',
'https://www.googleapis.com/auth/apps.order',
'https://www.googleapis.com/auth/admin.directory.user.readonly',
'https://www.googleapis.com/auth/admin.directory.domain',
'https://www.googleapis.com/auth/admin.directory.domain.readonly',
'https://www.googleapis.com/auth/calendar.readonly' ,
'https://www.googleapis.com/auth/drive.readonly',
'https://www.googleapis.com/auth/admin.directory.user',
'https://www.googleapis.com/auth/cloud-platform'      
 
 ]
#dominio que sera pesquisado 
TARGET='dominio.test.com'

#credenciais de acesso 
credentials = ServiceAccountCredentials.from_json_keyfile_name('./chave.json', scopes)
delegated_credentials = credentials.create_delegated('[email protected]')


http_auth = credentials.authorize(Http())

service = googleapiclient.discovery.build('admin', 'directory_v1', 
credentials=delegated_credentials)

response = service.activities().list(users='all',applicationName='chat')

print(response)

I've already used this code for other queries and it's working for accessing the directory and listing users but when I tried to adapt it to query chat activities it doesn't work I have the following error

    response = service.activities().list(customerId='all',applicationName='chat')
    AttributeError: 'Resource' object has no attribute 'activities'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文