You Are Not Authorized For This Operation. Invalid Access Token DialogFlow V2
Solution 1:
You don't show the baseUrl
you're using, but that looks like the V1 API rather than the V2 API. You should migrate your code to V2.
Keep in mind, also, that the access token expires, so you will need to generate a new one periodically. You cannot request a "long lived" token (this is considered insecure), but should have your code call gcloud auth print-access-token
(or use a library to do the same thing) before the previous one expires.
Update based on your code once you've moved it to V2:
The queryInput
parameter doesn't take a string directly. It must be set to a QueryInput object. This is an enum, so can only have one of the fields specified set. It looks like you want the text
field which requires a TextInput object.
So your body
parameter might be setup something like this:
var body = {
queryInput: {
text: {
text: "Hello",
language: "en-US"
}
}
};
var bodyStr = JSON.stringify(body);
and then set in your request()
options.
Solution 2:
Because you have put wrong URL in your project.
Open below image and see which URL use for posturl in your project
Post a Comment for "You Are Not Authorized For This Operation. Invalid Access Token DialogFlow V2"