是否可以在没有 Google Apps 域的情况下将 Google Calendar API v3 与服务帐户一起使用?
基本上我想要做的是使用python脚本在我自己的日历上创建一个事件,而没有脚本提示我输入用户和密码......有人知道吗?
我使用了这段代码,但没有运气:
import pprint
import pytz
import httplib2
import requests
from datetime import datetime, timedelta
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
with open('/home/xpto/service_account_certificate.pem', 'rb') as f:
key = f.read()
service_account_name = '000000000000-j...@developer.gserviceaccount.com'
credentials = SignedJwtAssertionCredentials(
service_account_name,
key,
scope=['https://www.googleapis.com/auth/calendar',
'https://www.googleapis.com/auth/calendar.readonly'],
sub='xpto@gmail.com')
http = httplib2.Http()
http = credentials.authorize(http)
service = build(serviceName='calendar', version='v3', http=http)
我收到此错误:
auth2client.client.AccessTokenRefreshError:未授权客户端:请求中的未授权客户端或范围