react-native-dialogflow
react-native-dialogflow copied to clipboard
Authentication V2: "status": "UNAUTHENTICATED"
Unable to get access
constructor(props) {
super(props);
Dialogflow_V2.setConfiguration(
"[email protected]",
'-----BEGIN PRIVATE KEY-----\nMIIEvgIBADAN...1oqO\n-----END PRIVATE KEY-----\n',
Dialogflow_V2.LANG_ENGLISH_US,
'testv2-3b5ca'
);
}
componentDidMount(){
Dialogflow_V2.requestQuery("Some text for your Dialogflow agent", result=>console.log(result), error=>console.log(error));
}
error recieved: {"error": {"code": 401, "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED"}}
I've tried generating new service accounts and making sure the API is enabled on the project. Any idea what could be causing this?
Sadly same issue here. Been stuck on this for over 2 weeks. Anyone got an alternative method?
This is how I do it:
const configureDialogFlow = (clientId: number | null) => {
Dialogflow_V2.setConfiguration(
env.DIALOGFLOW_CLIENT_EMAIL,
env.DIALOGFLOW_PRIVATE_KEY,
Dialogflow_V2.LANG_ENGLISH_GB,
env.DIALOGFLOW_PROJECT_ID,
);
const permanentContexts = [
{
name: 'Auth',
parameters: {
lifespanCount: 100,
AccessToken: clientId,
},
},
];
Dialogflow_V2.setPermanentContexts(permanentContexts);
};
Does anyone know a solution to this? The previous post requires TypeScript
Same here.
Hello, has anyone figured this out? I'm facing the same problem and have been stuck on this for weeks
I am using Expo and was having the same problem,
I checked my package.json, and it was using version "^3.1.0"
I changed to "3.1.1" and npm i
and restarted.
Now, it works!
this is my onSend function
const onSend = async (message) => {
setMessages((previousMessages) => GiftedChat.append(previousMessages, message));
let msg = message[0].text;
try {
const result = await new Promise((resolve, reject) => {
Dialogflow_V2.requestQuery(
msg,
(result) => {
resolve(result);
},
(error) => {
reject(error);
}
);
});
console.log(result);
handleGoogleResponse(result.queryResult.fulfillmentText);
} catch (error) {
console.error(error);
}
};