403禁止的错误google plus python

403禁止的错误google plus python,python,oauth,google-plus,Python,Oauth,Google Plus,以下是我的代码: import pprint import httplib2 from apiclient.discovery import build from oauth2client.client import OAuth2WebServerFlow SCOPES = ['https://www.googleapis.com/auth/plus.me', 'https://www.googleapis.com/auth/plus.stream.write'] RE

以下是我的代码:

import pprint
import httplib2

from apiclient.discovery import build
from oauth2client.client import OAuth2WebServerFlow

SCOPES = ['https://www.googleapis.com/auth/plus.me',
          'https://www.googleapis.com/auth/plus.stream.write']

REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob'

CLIENT_ID = "my client id"
CLIENT_SECRET = "my client secret"
flow = OAuth2WebServerFlow(client_id=CLIENT_ID,
                           client_secret=CLIENT_SECRET,
                           scope=SCOPES,
                           redirect_uri=REDIRECT_URI)

auth_uri = flow.step1_get_authorize_url()

print 'Please paste this URL in your browser to authenticate this program.'
print auth_uri
code = raw_input('Enter the code it gives you here: ')

credentials = flow.step2_exchange(code)

http = httplib2.Http()
http = credentials.authorize(http)
service = build('plusDomains', 'v1', http=http)

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))
这是我的错误:

Traceback (most recent call last):
      File "/home/karl/workspace/googleplus/google_plus/google_plus_pic.py", line 44, in <module>
        'domainRestricted': False
      File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 128, in positional_wrapper
        return wrapped(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/apiclient/http.py", line 680, in execute
        raise HttpError(resp, content, uri=self.uri)
    apiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/plusDomains/v1/people/me/activities?alt=json returned "Forbidden">
回溯(最近一次呼叫最后一次):
文件“/home/karl/workspace/googleplus/google\u plus/google\u plus\u pic.py”,第44行,在
“domainRestricted”:False
文件“/usr/local/lib/python2.7/dist packages/oauth2client/util.py”,第128行,位于位置包装器中
已包装退货(*args,**kwargs)
文件“/usr/local/lib/python2.7/dist packages/apiclient/http.py”,第680行,在execute中
raise HttpError(resp,content,uri=self.uri)
apiclient.errors.HttpError:
我读了很多资料,但我不知道如何解决这个问题。
错误在哪里?

要使用Google+域API,您需要确保您所代表的用户的域已设置为具有应用程序的正确权限。这些说明位于本指南步骤1的“将域范围的权限委托给您的服务帐户”部分


具体来说,您需要将应用程序的客户端ID与应用程序将在域的控制面板中使用的作用域相关联。域管理员是唯一可以这样做的人——因此,如果您正在使用另一个域,请确保与该人取得联系。此外,控制面板中列出的作用域必须与您在应用程序中请求的作用域完全匹配。

为了确保您授权的谷歌帐户是谷歌应用程序帐户,对吗?