2015-09-12 23 views
0

我使用這個鏈接創建的谷歌加上帖子 - https://developers.google.com/+/domains/posts/creating面對解析錯誤問題與谷歌plusDomains REST API在創建後

我一直在使用這些步驟

  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 
    

[R esult

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

接收到該代碼 「4/OxhUqnNDDGPPcuf_VvE7cKuL4PXehuToUTfwyrt9U」 與重定向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}" 
        } 
    

    現在建立在谷歌後加上下面捲曲請求,利用上述訪問令牌時,我得到了解析錯誤 -

    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。

    我不知道我在做什麼錯在這裏。任何幫助將不勝感激。

    回答

    1

    試試這個: -

    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"

    +0

    是它解決了解析錯誤,但現在的問題是403錯誤 –

    +0

    要建立你必須有谷歌的域帳戶憑據的活動。 – Mahendra