Harish Lalwani Harish Lalwani - 1 month ago 10
PHP Question

Facing parse error issue with google plusDomains rest api while creating post

I am using this link for creating posts on google plus -
https://developers.google.com/+/domains/posts/creating

I have generated access token using these steps


  1. Using the following link to generate code

    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



result

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


received this code "4/OxhUqnNDDGPPcuf_VvE7cKuL4PXehuToUTfwyrt9U" with redirect uri.


  1. Using this code I made a request for token at this url

    https://www.googleapis.com/oauth2/v3/token



post params -

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


for which received following result

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


Now when creating a post on google plus using the above access token in following curl request I get the parse error -

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


Results -

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


There is no description for this error code at the following link -
https://developers.google.com/drive/web/handle-errors

And using both these permissions

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


As suggested by mahendar it does solves the parse error which I figured earlier today. But now I am facing the following issue of

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


I guess the permissions are wrong. I have enabled the domainPlus api in developers console.

I don't know what I am doing wrong here. Any help will be appreciated.

Answer Source

try this:-

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"