0

I want to be able create calendar events in my Action that runs through Google Assistant.

Right now I was able to modify this Quickstart guide (https://developers.google.com/calendar/quickstart/nodejs) and use it in my current Dialogflow fulfillment. However, it's a little tedious to have the user have to copy and paste the authentication code after allowing Google Calendar access. Are there any better ways to do this that doesn't require the copy-paste flow? Thanks in advance!

SST
  • 13
  • 4

2 Answers2

0

Use Account linking with Google Sign-In

https://developers.google.com/actions/identity/google-sign-in

Then send a card to the user device with a link to authorise Google Calendar access. Store the authentication code securely against the user. Use the authentication code to make requests.

Bcf Ant
  • 1,639
  • 1
  • 16
  • 26
  • I am currently using account linking with Google Sign-In, but that only gives access to the user's name, email, and profile picture. Could you elaborate more on sending a card and storing the code? Thanks! – SST Aug 06 '19 at 15:57
0

Broadly speaking, the approach you can take is to use Google Sign-In, as outlined in this SO answer: Google Home Authorization Code and Authentication with Google Account.

With this scheme, you use a website to get the user to authorize your use of the Calendar API scope, and you store the auth token against their UserID. Then you use Google Sign-In with the Assistant to get that ID. This works well if they go to your web page first, but not as well if they go to the Assistant first.

You can also setup an OAuth server that lets users sign-in using Google Sign-In on a web page (or use something like Auth0 and, as part of that sign-in, get authorization for the Calendar scope. Then use OAuth Account Linking in the Google Assistant to get an auth token which you can use to get the user's ID. You can then use this ID to lookup the authorization token.

Prisoner
  • 49,922
  • 7
  • 53
  • 105