在Google+上分享帖子时出现HttpError 403

时间:2014-11-02 22:26:24

标签: oauth-2.0 google-api google-plus google-oauth google-api-python-client

我正在尝试通过Google+将帖子插入到我自己的Python API个人资料中,但是我一直都在失败。我正在按照教程here进行操作。我激活了Google+ Domains APIGoogle+ API,并为教程中的示例创建了本机应用程序凭据。

以下代码段显示了我发布到Google API的方式:

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'
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'
result = service.activities().insert(
    userId = user_id,
    body = {
        'object' : {
            'originalContent' : 'Happy Monday! #caseofthemondays'
        },
        'access' : {
            'items' : [{
                'type' : 'domain'
            }],
            'domainRestricted': True
        }
    }).execute()

请求返回以下错误:

  

apiclient.errors.HttpError:https://www.googleapis.com/plusDomains/v1/people/me/activities ?alt = json   返回“禁止”>

你知道如何解决这个问题吗?

我在浏览器中同意能够写帖子为什么会被禁止?

0 个答案:

没有答案