Miniflexa
Miniflexa

Reputation: 91

Use Google home access token in the webhook

I have a webhook for my Google home app. The app sends an accessToken to my webhook but I have trouble accesing it in the actions-on-google V2.

This is what it looks like in the webhook right now. variable 'token' returns Undefined right now. How do I access the accessToken Correctly?

app.intent('help', (conv , params) => {
 var help = conv.parameters[Parameters.HELP];
 var token = conv.user.accessToken;
 var API_URL_HELP = API_URL+"&call=help&answer="+help+"&token="+token;

 var options = {
    uri: API_URL_HELP,
    json: true 
 };

 return rp(options)
    .then( response => {
    console.log( 'response:', JSON.stringify(response,null,1) );
    var value = response.msg;
    return conv.close( value );
 });
});

Upvotes: 2

Views: 96

Answers (1)

Prisoner
Prisoner

Reputation: 50741

The field you want is conv.user.access.token. So

 var token = conv.user.access.token;

should work.

Upvotes: 1

Related Questions