在创建 post 时遇到 google plusDomains rest api 的解析错误问题
Facing parse error issue with google plusDomains rest api while creating post
我正在使用这个 link 在 google 上创建 post 加上 -
https://developers.google.com/+/domains/posts/creating
我已经使用这些步骤生成了访问令牌
使用下面的link生成代码
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#
收到带有重定向 uri 的代码“4/OxhUqnNDDGPPcuf_VvE7cKuL4PXehuToUTfwyrt9U”。
使用此代码,我在此 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 上创建 post 并在以下 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"
}
}
以下link-没有对此错误代码的描述
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"
我正在使用这个 link 在 google 上创建 post 加上 - https://developers.google.com/+/domains/posts/creating
我已经使用这些步骤生成了访问令牌
使用下面的link生成代码
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#
收到带有重定向 uri 的代码“4/OxhUqnNDDGPPcuf_VvE7cKuL4PXehuToUTfwyrt9U”。
使用此代码,我在此 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 上创建 post 并在以下 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"
}
}
以下link-没有对此错误代码的描述 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"