我想制作一些应用程序(Google App Engine),它将从其他网站获取一些数据并将它们发布到我在 Google+ 中的“收藏”之一中。
现在我有这个代码:main.py
# -*- coding: utf-8 -*-
import webapp2
import httplib2
from googleapiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
class UpdateChannelTask(webapp2.RequestHandler):
def get(self):
self.add_news()
def add_news(self):
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'my_project.json',
(
'https://www.googleapis.com/auth/plus.me',
'https://www.googleapis.com/auth/plus.stream.write'
)
)
delegate_credentials = credentials.create_delegated('my_email@gmail.com')
http = httplib2.Http()
http = delegate_credentials.authorize(http)
service = build(
'plusDomains',
'v1', http=http)
service.activities().insert(
userId='me',
preview=True,
body={
'object': {
'originalContent': 'Test, my first post in Google+!'
},
'access': {
'items': [{
'type': 'domain'
}],
'domainRestricted': True
}
}).execute()
app = webapp2.WSGIApplication(
routes=[
(r'/update', UpdateChannelTask),
],
debug=True
)
但这不起作用,我得到错误
HttpError: <HttpError 403 when requesting https://www.googleapis.com/plusDomains/v1/people/me/activities?alt=json&preview=true returned "Forbidden">
我的应用如何获得发布到我的 Google+ 收藏集的权利?
//edit 我是否正确理解了这份文件?我需要有付费帐户“Google for Work”来解决我的问题吗?
我所做的一切都是根据链接做的。在将域范围的权限委托给您的服务帐户部分中,我必须转到 URL https://www.google.com/a/cpanel/my_app.appspot.com并设置一些东西。尝试去那里给我屏幕“您需要一个 Google for Work 帐户才能登录 my_app.appspot.com。了解更多”。所以我需要“Google for Work”?