他のウェブサイトからデータを取得し、Google+ の「コレクション」の 1 つに投稿するアプリケーション (Google App Engine) を作成したいと考えています。
今のところ、私はこのコードを持っています: 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+ コレクションに投稿する権利を取得するにはどうすればよいですか?
//編集 このドキュメントを正しく理解していますか? 問題を解決するには有料アカウント「Google for Work」が必要ですか?
私がすることはすべてlinkに従って行います。ドメイン全体の権限をサービス アカウントに委任するセクションで、URL https://www.google.com/a/cpanel/my_app.appspot.comにアクセスして何かをセットアップする必要があります。そこに行こうとすると、「ログインするには my_app.appspot.com の Google for Work アカウントが必要です。詳細はこちら」という画面が表示されます。「Google for Work」が必要ですか?