面对解析错误的问题与谷歌plusDomains rest api,而创建后



我使用这个链接在google plus上创建帖子域https://developers.google.com/+//文章/创建

我使用以下步骤生成了访问令牌

  1. 使用下面的链接生成代码

    https://accounts.google.com/o/oauth2/auth?client_id={client_id}&redirect_uri={redirect_uri}&scope=https://www.googleapis.com/auth/plus.stream.write https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me&approval_prompt=force&response_type=code
    
结果

    {redirect_uri}/?code=4/OxhUqnNDDGPPcuf_VvE7cKuL4PXehuToUTfwyrt9U&authuser=0&prompt=consent&session_state=7da4522b3012e15uigggguhgue1bd80e6adb1bfd9..66de#

收到此代码"4/oxhuqnnddgppcuf_vve7ckul4pxehuoutfwyrt9u ",重定向uri。

  • 使用这个代码,我在这个url

    请求令牌
    https://www.googleapis.com/oauth2/v3/token
    
  • post参数

        grant_type = authorization_code
        code = 4/OxhUqnNDDGPPcuf_VvE7cKuL4PXehuToUTfwyrt9U
        client_secret = {client_secret}
        redirect_uri = {redirect_uri}
        client_id = {client_id}
    

    接收到以下结果

     {
    "access_token": "{access_token}",
    "token_type": "Bearer",
    "expires_in": 3600,
    "id_token": "{token_id}"
      }
    

    现在,当在google plus上使用上述访问令牌在以下curl请求中创建帖子时,我得到解析错误-

     curl -v -H "Content-Type: application/json" -H "Authorization: Bearer "{access_token}" -d "{"object": {"originalContent": "Happy Monday!#caseofthemondays"},"access":{"kind":"plus#acl","items":[{"type":"domain"}],"domainRestricted":true}}" -X POST https://www.googleapis.com/plusDomains/v1/people/{user_id}/activities
    
    ——

    结果

      {
       "error": {
         "errors": [
           {
             "domain": "global",
             "reason": "parseError",
             "message": "Parse Error"
           }
        ],
         "code": 400,
       "message": "Parse Error"
       }
     }
    

    下面的链接-中没有此错误代码的说明https://developers.google.com/drive/web/handle-errors

    使用这两个权限

      https://www.googleapis.com/auth/plus.me
      https://www.googleapis.com/auth/plus.stream.write
    

    正如mahendar所建议的,它确实解决了我今天早些时候发现的解析错误。但现在我面临着以下问题

      {
        "error": {
          "errors": [
            {
              "domain": "global",
              "reason": "forbidden",
              "message": "Forbidden"
            }
          ],
          "code": 403,
          "message": "Forbidden"
        }
      }
    

    我猜权限是错误的。我已经在开发人员控制台中启用了domainPlus api。

    我不知道我在这里做错了什么。

    试试这个:-

    curl -v -H "Content-Type: application/json" -H "Authorization: Bearer {{access_token}}" -d '{"object": {"originalContent": "Happy Monday!#caseofthemondays"},"access":{"kind":"plus#acl","items":[{"type":"domain"}],"domainRestricted":true}}' -X POST "https://www.googleapis.com/plusDomains/v1/people/me/activities"

    相关内容

    • 没有找到相关文章

    最新更新