我使用OAuth2.0和Google服务帐户来尝试和管理日历。下面提供了Python中的示例代码:
from oauth2client.client import SignedJwtAssertionCredentials
from httplib2 import Http
from apiclient.discovery import build
client_email = "<service_account_client_email>"
with open("key.p12") as f:
priv_key = f.read()
cred = SignedJwtAssertionCredentials(client_email, priv_key, "https://www.googleapis.com/auth/calendar", sub="<user_to_impersonate>")
http_auth = cred.authorize(Http())
service = build(serviceName='calendar', version='v3', http=http_auth)
到目前为止,我在运行代码时得到了一个异常“required client not authorized”。
我遵循了谷歌文档中的步骤:
我错过了什么步骤?我的范围仅仅用于构建服务是否不正确?
目前没有回答
相关问题 更多 >
编程相关推荐