0

我的 Fulfillment End Point 没有收到 accessToken。这是正常的吗?因为当我在模拟器上时,它并没有真正要求登录到我的授权端点,因此它不会获得访问令牌。在使用 Oauth Play Ground 进行测试后,我的 Oauth 运行良好。

动作.json

    {
"accountLinking": {
    "clientId": "",          // SENSITIVE INFORMATION BLANK
    "clientSecret": "",       // SENSITIVE INFORMATION BLANK
    "grantType": "AUTH_CODE", 
  "authenticationUrl": "",      // SENSITIVE INFORMATION BLANK
  "accessTokenUrl": ""          // SENSITIVE INFORMATION BLANK


  },
  "actions": [{
        "description": "",
        "name": "MAIN",
        "fulfillment": {
            "conversationName": "PASS TEXT"
        },
        "intent": {
            "name": "actions.intent.MAIN",
            "trigger": {
                "queryPatterns": [
                    "talk to APP NAME"
                ]
            }
        }
    }],

 "conversations": {
        "PASS TEXT": {
            "name": "PASS TEXT",
            "url": ""  // MY FULFILLMENT END POINT
            "fulfillmentApiVersion": 2
        }
    }
}

履行收到的请求

请求已记录到文本文件中

jsondata = file_get_contents('php://input');
$postdata = json_decode($jsondata, true);

$RAWfile = print_r($postdata, true);
file_put_contents('RAWfile.txt', $RAWfile);

RAWfile.txt

   Array
(
    [user] => Array
        (
            [userId] => APhe68HH0PP0nTYnY8jBJed31WqF
            [locale] => en-US
        )

    [conversation] => Array
        (
            [conversationId] => 1500924702161
            [type] => NEW
        )

    [inputs] => Array
        (
            [0] => Array
                (
                    [intent] => actions.intent.MAIN
                    [rawInputs] => Array
                        (
                            [0] => Array
                                (
                                    [inputType] => VOICE
                                    [query] => ask APP NAME to bla bla
                                )

                        )

                    [arguments] => Array
                        (
                            [0] => Array
                                (
                                    [name] => trigger_query
                                    [rawText] => bla bla
                                    [textValue] => bla bla
                                )

                        )

                )

        )

    [surface] => Array
        (
            [capabilities] => Array
                (
                    [0] => Array
                        (
                            [name] => actions.capability.AUDIO_OUTPUT
                        )

                )

        )

    [device] => Array
        (
        )

    [isInSandbox] => 1
)

模拟器请求

{
    "query": "bla bla",
    "accessToken": "ya29.Gl2TBLrbKjcgK-6jsARmc4Zvkx8qT2X2rE3vsuwEVc_Ey2-q4OUqNWaJPBlXzIjONb_u2MbrE-rgnfwQSZpbZReXsmZjoGOy18Tvp7xzzSJb-cW9SjZ32uLBaKO7vGE",
    "expectUserResponse": true,
    "conversationToken": "CiZDIzU5O...",
    "surface": "GOOGLE_HOME",
    "inputType": "VOICE",
    "locale": "en-US",
    "location": {
        "address": "Googleplex, Mountain View, CA, United States",
        "position": {
            "lat": 37.421980615353675,
            "lng": -122.08419799804688
        },
        "zipCode": "94043",
        "city": "Mountain View"
    },
    "debugInfo": {
        "assistantToAgentDebug": {
            "assistantToAgentJson": {
                "user": {
                    "userId": "bla",
                    "locale": "en-US"
                },
                "conversation": {
                    "conversationId": "1501004260313",
                    "type": "NEW"
                },
                "inputs": [
                    {
                        "intent": "actions.intent.MAIN",
                        "rawInputs": [
                            {
                                "inputType": "VOICE",
                                "query": "bla"
                            }
                        ],
                        "arguments": [
                            {
                                "name": "trigger_query",
                                "rawText": "bla",
                                "textValue": "bla"
                            }
                        ]
                    }
                ],
                "surface": {
                    "capabilities": [
                        {
                            "name": "actions.capability.AUDIO_OUTPUT"
                        }
                    ]
                },
                "device": {},
                "isInSandbox": true
            }
        }
    }
}

模拟器响应

{
    "response": "Sure. Here's the test version of bla.\nsure\n",
    "conversationToken": "bla",
    "audioResponse": "//NExAASS...",
    "debugInfo": {
        "agentToAssistantDebug": {
            "agentToAssistantJson": {
                "conversationToken": "{\"state\":null,\"data\":{}}",
                "expectUserResponse": false,
                "finalResponse": {
                    "richResponse": {
                        "items": [
                            {
                                "simpleResponse": {
                                    "textToSpeech": "sure",
                                    "displayText": "sure"
                                }
                            }
                        ],
                        "suggestions": []
                    }
                }
            }
        }
    }
}
4

2 回答 2

1

帐户链接是通过位于https://console.actions.google.com/的操作控制台完成的

从“概览”菜单项,您需要进入第 5 步:帐户关联。

在那里,您可以设置您的端点、所需的范围等。

于 2017-07-24T20:28:50.677 回答
0

认为您必须手动完成该部分 - 如果您查看响应,您会看到一个 URL - 复制/粘贴并运行它,它应该完成帐户链接过程 - https://developers.google.com/actions/身份/帐户关联

“在日志区域中,将 debugInfo.sharedDebugInfo.debugInfo 字段中的 URL 复制并粘贴到您的 Web 浏览器中。您将被重定向到在 API.AI 或操作控制台中指定的您自己的服务器的身份验证 URL。”

于 2017-07-25T18:16:02.447 回答