I want to make some application (Google App Engine) which will be fetching some data from other websites and post them in one of my "collections" in Google+.
For now I have this code: 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
)
but this does not work, I get error
HttpError: <HttpError 403 when requesting https://www.googleapis.com/plusDomains/v1/people/me/activities?alt=json&preview=true returned "Forbidden">
How can my app gain right to post to my Google+ collection?
//edit Am I understand this document correctly? I need to have paid account "Google for Work" to solve my problem?
Everything I do I do according to link. In section Delegate domain-wide authority to your service account I have to go to URL https://www.google.com/a/cpanel/my_app.appspot.com and setup something. Attempt to go there gives me screen with "You need a Google for Work account for my_app.appspot.com to login. Learn more". So I need "Google for Work"?