我正在尝试使用最近发布的 Google Meet API 从 google meet 记录中获取详细信息和工件。我想进行服务器到服务器 API 调用,因此创建了一个可以访问 Google Meet API 的服务帐户。
我还在控制台中启用了 Google Meet API。
我的做法:
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_file(
filename='ultra-might-424911-b1-9f5cf95d5846.json',
scopes=["https://www.googleapis.com/auth/meet.recordings.readonly"] # Add the required scope
)
client = meet_v2.ConferenceRecordsServiceClient(credentials=credentials)
request = meet_v2.GetRecordingRequest(name="xxx-xxxx-xxx")
response = client.get_recording(request=request)
print(response)
范围值来自 https://developers.google.com/meet/api/guides/overview#auth (但是这些范围不存在于 https://developers.google.com/identity/protocols/oauth2/scopes )
此操作失败:
google.api_core.exceptions.RetryError: Timeout of 60.0s exceeded, last exception: 503 Getting metadata from plugin failed with error: ('invalid_scope: https://www.googleapis.com/auth/meet.recordings.readonly is not a valid audience string.', {'error': 'invalid_scope', 'error_description': 'https://www.googleapis.com/auth/meet.recordings.readonly is not a valid audience string.'})
我也尝试过这种方法https://developers.google.com/identity/protocols/oauth2/service-account#jwt-auth 但这失败并显示消息:
"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project."
此时,我已经花了几个小时,不知道如何克服这个问题。寻求任何帮助或建议。
如果我没记错的话,你正在使用方法:conferenceRecords.get
如果您检查文档,它会告诉您需要什么范围,这是其中之一
您似乎正在使用服务帐户。 您可能还需要仔细检查您是否已在 Google Workspace 域中正确配置服务帐户服务帐户凭据