I was using V1 API to make requests for a while. I am looking to upgrade from V1 to V2 API.
I am using this python code to make requests:
import os.path
import sys
import json
try:
import apiai
except ImportError:
sys.path.append(
os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir)
)
import apiai
#CLIENT_ACCESS_TOKEN = 'client access token'
def main():
try:
ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN)
request = ai.text_request()
request.lang = 'en' # optional, default value equal 'en'
request.query = "techm bid satyam computers" #Enter question here
response = request.getresponse()
hi=json.loads(response.read())
res=hi
print (res)
except TimeoutError:
print ("Couldn't connect to dialogflow")
if __name__ == '__main__':
main()
What I tried to migrate to V2 API is,
- I created a service account with 'DialogFlow API client' Role.
- Created a private key and set it as GOOGLE_APPLICATION_CREDENTIALS
- Deleted the client access token and tried to access
It showed IAM permission denied, Client access token does not exists errors.
Is there a separate python code for V2 API to access dialogflow?