In the Dialogflow version 1 API, you only need an authentication token to access the Dialogflow API. However, in version two, Google completely changed their approach by using the Google platform Service Account to authenticate the Dialogflow API.
- Log in to Dialogflow
- Click on the FortuneCookie agent setting
- Click on the Service Account link
The following screenshot shows the FortuneCookie Service Account:
![](assets/8b23b211-3fb6-48d7-8101-a7e5be24f629.png)
Fortune Cookie agent service account
Take note of theĀ Project ID here, which you will be using in the Creating test script using Dialogflow client SDK section.
- You will be directed to Google Cloud Platform. From the menu, go to IAM & admin, and then go to Service accounts.
The following screenshot shows the Google Cloud Platform Service Accounts page:
![](assets/cd09ac38-89c6-4e15-aba0-0ed4ee030560.png)
Google Cloud Platform Service Accounts
- Click on CREATE SERVICE ACCOUNT. Enter the service account name as fortunecookietest. Choose the Dialogflow roles: Dialogflow API Admin, Dialogflow API Client, and Dialogflow API Reader. Choose Furnish a new private key with JSON as an option. Click Create.
The following image shows the settings for creating a service account:
![](assets/3f895d02-02ec-4d87-9345-4e5f3caef896.png)
Google Cloud Platform Create service account
- You will be asked to download a JSON file that contains the authentication key. You will need this key to set up your machine to access the FortuneCookie Dialogflow intents via the client SDK.
- Install the Google Cloud SDK (http://bit.ly/2ukc8iA).
- Start the Cloud SDK shell and run gcloud init. This will initialize your machine to be able to use Google Cloud Platform services.
- Create a Windows environment variable, which sets the Google application credential file GOOGLE_APPLICATION_CREDENTIALS="Authentication JSON Key File Path". You downloaded this JSON key file in step 6.
The following screenshot shows the Windows variable environment setting for GOOGLE_APPLICATION_CREDENTIALS.
![](assets/9ff47988-7d17-49c1-bf41-5f65820cf2ba.png)
Google Cloud Platform Windows Environment Variables
- Restart your computer.