Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
error 401 - no authorization
'use strict';
const AWS = require('aws-sdk');
AWS.config.update({ region: 'us-east-1' })
const { dialogflow, SignIn } = require('actions-on-google');
const app = dialogflow();
const request = require('request-promise')
const rp = require('request-promise');
// Start SignIn Intention is assigned to the 'sign in' Training phrase
app.intent('Start SignIn', (conv) => {
conv.ask(new SignIn('To get your account details'));
// Get SignIn Intention is assigned to the 'Google Assistant Sign In' action
app.intent('Get SignIn', (conv, params, signin) => {
// tutaj występuje Error 401 - brak autoryzacji
if (signin.status === 'OK') {
const accessToken = conv.body.originalDetectIntentRequest.payload.user.accessToken;
const options = {
method: 'GET',
uri: '',
headers: {
authorization: 'Bearer ' + accessToken
return rp(options).then(function (body) {
let data = JSON.parse(body);
conv.ask(`I got your account details, ${}. What do you want to do next?`);
}).catch(function(err) {
conv.ask(`Sorry, but I could not sign you in.`);
} else {
conv.ask(`Sorry, but there was an error, and I could not sign you in.`);
app.intent('Default Welcome Intent', conv => {
conv.ask("Hello from Welcome Intent, udalo sie");

This comment has been minimized.

Copy link

@himangipatel himangipatel commented Aug 2, 2019

did you get any solution? I am facing the same issue


This comment has been minimized.

Copy link
Owner Author

@pawelgagorowski pawelgagorowski commented Aug 3, 2019

hi there, first of all, the code is ok - it was somewhere in the action's configuration - don't know where exactly.
Maybe simply an action can not tolerate changing the configuration while the application is running - what I can advise you is to create a new action and carefully enter the data. Let me know if that helped..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment