このガイドはQuick start for Pythonです。新しいGoogleドメインのアクティビティを投稿する際のエラー
Google AppsドメインコントロールパネルにアクセスするためのG-Suiteアカウントも作成しました。ここで
ポスト挿入する私のコード:クライアントIDを取得するには
__author__ = '[email protected] (Joanna Smith)'
import httplib2
import pprint
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
SERVICE_ACCOUNT_EMAIL = '[email protected]'
SERVICE_ACCOUNT_PKCS12_FILE_PATH = './ProjectTest-9179fae1c392.json'
USER_EMAIL = '[email protected]'
SCOPES = ['https://www.googleapis.com/auth/plus.me','https://www.googleapis.com/auth/plus.stream.write']
def authenticate():
print 'Authenticate the domain for %s' % USER_EMAIL
credentials = ServiceAccountCredentials.from_json_keyfile_name(
SERVICE_ACCOUNT_PKCS12_FILE_PATH, scopes=SCOPES)
delegate_credentials = credentials.create_delegated(USER_EMAIL)
http = httplib2.Http()
http = delegate_credentials.authorize(http)
return build('plusDomains', 'v1', http=http)
def activitiesInsert(service):
user_id = 'me'
print('Insert activity')
result = service.activities().insert(
userId = user_id,
body = {
'object' : {
'originalContent' : 'Happy Monday! #caseofthemondays'
}
'access' : {
'items' : [{
'type' : 'domain'
}],
'domainRestricted': True
}
}).execute()
print('result = %s' % pprint.pformat(result))
if __name__ == '__main__':
service = authenticate()
activitiesInsert(service)
は私がサービスアカウントキーの「ドメイン全体Gスイートの委任を有効にする」をチェックしなければならない、と私は、クライアントIDにスコープを追加しましたGoogle Appsドメインコントロールパネルから
しかし、私はこのエラー私のコードのそれの出力を実行します。
<HttpError 403 when requesting https://www.googleapis.com/plusDomains/v1/people/me/activities?alt=json returned "Forbidden">
なぜ?
このフォームに登録する必要がありますか? https://developers.google.com/+/web/api/rest/pages-signup
EDIT:私は認可のスクリーンショットを行った、それは私には大丈夫だと思われる。
更新:最初にアクセスしたときにGoogle+を設定しました。 –