1

このガイドは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:私は認可のスクリーンショットを行った、それは私には大丈夫だと思われる。

enter image description here

enter image description here

enter image description here

enter image description here

+0

更新:最初にアクセスしたときにGoogle+を設定しました。 –

答えて

0

403 forbiddenあなたはそれはあなたがやろうとしているで、これまで何をする権限を持っていないことを意味します。この場合は、ドメインのアクティビティページに挿入します。最初に行う必要があるのは、サービスアカウントがドメインアカウントに追加されたことを再確認し、必要な権限があることです。これは役に立ちますPerform Google Apps domain-wide delegation of authority

これは、使用しているGoogle+ドメインAPIです。これにより、ドメインのアカウントアクティビティページに投稿されます。これは​​に何かを投稿するつもりはありません。

Google Plus pages APIは、Google+のソーシャルメディアウェブサイトのページに投稿するためのものです。それはプライベートベータ版です。

+0

私の投稿を編集しました。私はいくつかのスクリーンショットを追加しました –

関連する問題