Google Calendar Authentication by API.AI with Google Actions

I am writing an API.AI application with Google actions (will be launched in Google Assistant and google home). The application should be able to read / add events to the user’s Google calendar account.

The backend is Google's cloud features, and I turned on the calendar API in the developer console.

The stream that the user should experience looks something like this:

User: "Hey Google, when was my last meeting with Anna?"

Agent: "Your last meeting with Anna was two days ago"

User: "Make an appointment with Anna for tomorrow"

Agent: "OK, meeting is installed."

How do I create an authentication process to give the application access to the calendar?

+2
source share
2 answers

Update November 8, 2017

As of October 4, 2017, Google has updated its policy to expressly prohibit this. Around the same time, they also took technical measures to prevent this.

The part about enabling the calendar API is still true, although not enough to complete the given source question.

Original answer

In a broad sense, the tasks that must be completed should consist of four parts:

  • Set up your project (in the cloud console) so that the calendar API is enabled and that the OAuth2 client is configured correctly.
  • Configure the "Action for account" link in the action console.
  • Configure actions in Google Integration for the API.AI agent to indicate that login is required.
  • API.AI webhook , JSON. API Google.

, API- Google , OAuth2.

Credential screen

  1. " ", " OAuth" Create Credentials

  2. , "-" (... kinda...)

  3. . "Action client", , Actions Google.

  4. " URI" URI https://oauth-redirect.googleusercontent.com/r/your-project-id, "--"... Cloud Console. : enter image description here

  5. "", . , . enter image description here

  6. "", " " . , - ( reset , ).

enter image description here

OAuth , Actions, , .

enter image description here

  1. " " "" .

enter image description here

  1. " " Cloud Console. ( , " API Cloud Console" .)

  2. URL https://accounts.google.com/o/oauth2/v2/auth

  3. URL- https://www.googleapis.com/oauth2/v4/token

  4. ""

enter image description here

  1. , . - . ( , .) "" .

enter image description here

  1. . , . - , "".

API.AI

API.AI , Action.

enter image description here

-

webhook ! OAuth :

  • JavaScript, app.getUser().authToken

  • JSON, originalRequest.data.user.accessToken

, API Google, , .

- , .

+4

Google , OAuth.

:

" Google OAuth, Google."

0

Source: https://habr.com/ru/post/1688956/


All Articles