나는 다른 웹 사이트에서 일부 데이터를 가져 오는 것 일부 응용 프로그램 (구글 앱 엔진)을하고 Google+의 내 "컬렉션"중 하나를 게시 할. 지금은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('[email protected]')
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+의 컬렉션에 게시 할 수있는 방법 ? // 편집
내가 올바르게 document을 이해하고 있습니까? 내 문제를 해결하기 위해 "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"가 필요합니까?
죄송 그것은 정답이 아니다 :] 내가 업데이트 한 질문입니다. – BPS
아니요, 직장에 Google 계정을 지불 할 필요가 없습니다. 이 범위를 추가하고 승인하면 토큰을 가져와 토큰을 사용하여 user_id를 가져온 다음 사용자 google + 계정에 활동을 추가합니다. 그것은 단순히 나를 위해 작동합니다. 내 프로젝트에 통합했습니다. –
[link] (https://developers.google.com/+/domains/quickstart/python)에 따라 모든 작업을 수행합니다. 섹션 ** 도메인 서비스 권한 위임 권한 **에서 URL [link] (https://www.google.com/a/cpanel/my_app.appspot.com)로 이동하여 설정해야합니다. "my_app.appspot.com에 로그인 할 때 Google for Work 계정이 필요합니다."자세한 정보가있는 화면이 표시됩니다. 그래서 "Google for Work"가 필요합니까? – BPS