[Dialogflow] Authenticate with API Key
Hello, I want to use dialogflow api within my project (for Gen App chat bot). But the authentication seems weird.
My server is hosted in Azure and most of third parties I use connect with API Token or API Key. Here with dialogflow I can't find any documentation mentioning it.
I don't want to authenticate with ADC, because it's complicated, unaesthetic, requires files from what I have understood so far. I just want to have a simple API key that I can provide to the client and then call my chatbot. Simple.
Here is the current code :
const sessionClient = new dialogflow.SessionsClient({
projectId,
});
export async function getUserIntent(
sessionId: string,
query: string,
contexts: any,
languageCode: string = 'fr'
) {
const sessionPath = sessionClient.projectAgentSessionPath(
projectId,
sessionId
);
const request = {
session: sessionPath,
queryInput: {
text: {
text: query,
languageCode,
},
},
queryParams: {},
};
if (contexts && contexts.length > 0) {
request.queryParams = {
contexts,
};
}
const responses = await sessionClient.detectIntent(request);
return responses[0];
}
But I have the following error :
Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at GoogleAuth.getApplicationDefaultAsync (C:\dev\repos\raskyer\la-plateforme\web\node_modules\google-auth-library\build\src\auth\googleauth.js:207:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at GoogleAuth.getClient (C:\dev\repos\raskyer\la-plateforme\web\node_modules\google-auth-library\build\src\auth\googleauth.js:624:17)
at GrpcClient._getCredentials (C:\dev\repos\raskyer\la-plateforme\web\node_modules\google-gax\build\src\grpc.js:145:24)
at GrpcClient.createStub (C:\dev\repos\raskyer\la-plateforme\web\node_modules\google-gax\build\src\grpc.js:308:23)
I have the exact same question, except in my case, I'm trying to use the new Google Maps Places API. Auth has gone from simply passing in a key to something I can no longer figure out how to do with a cloud provider like Azure. What a downgrade!