Elo97234c
Elo97234c

Reputation: 193

Not Receiving AccessToken on Simulator

My Fulfilment End Point isnt receiving accessToken. Is this normal? Becouse when im on the simulator it doesnt really ask to login to my authorization end point thus, it wont get a access token. My Oauth is working perfectly after tesing with Oauth Play Ground.

action.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
        }
    }
}

Fulfilment Received Request

The request was logged into a text file

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
)

Simulator Request

{
    "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
            }
        }
    }
}

Simulator Response

{
    "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": []
                    }
                }
            }
        }
    }
}

Upvotes: 0

Views: 296

Answers (2)

Madgeni
Madgeni

Reputation: 65

Think you have to manually complete that part - if you look in the response, you'll see a URL - copy/paste and run that, it should complete the account linking process - https://developers.google.com/actions/identity/account-linking

"In the Log area, copy and paste the URL from the debugInfo.sharedDebugInfo.debugInfo field into your web browser. You will be redirected to the authentication URL for your own server that was specified in API.AI or in the Actions Console."

Upvotes: 0

Prisoner
Prisoner

Reputation: 50741

Account linking is done through the Actions Console at https://console.actions.google.com/

From the "Overview" menu item, you'll need to get to step 5: Account Linking.

In there, you can set your endpoints, scopes required, etc.

Upvotes: 1

Related Questions