Rainmaker
Rainmaker

Reputation: 23

AoG: DialogFlow + OAuth2.0

Is there any sample code that uses DialogFlow with Google OAuth2.0?

There should be an oauthcallback and token endpoints but I can't seem to find any code to use.

This is for the account linking authorisation url and token url.

Upvotes: 2

Views: 1020

Answers (1)

Prisoner
Prisoner

Reputation: 50701

You won't find any sample code for the callback and token endpoints because these aren't actually related to Dialogflow. Dialogflow doesn't offer these services and relies on the underlying messaging service (Actions on Google in this case) to have implemented authentication or account linking.

Actions on Google has a very wide variety of authentication/linking and basic identity options, depending on your exact needs. You don't say why you're trying to do this, so it is difficult to give you an exact answer.

  • In the most simple case, if you just need to know that you're seeing the same user that you've seen before you can use the anonymous user ID abilities.

  • If you need something like their name or location, you can ask for permission for this.

  • If you just need the Google Profile they have used with their Assistant, you can request that they sign into your Action with their Google Sign In. This will include their Google ID and the email address, which you can use to link to their account in your system if you keep track of this info in your account.

  • If you need something more advanced, and you need them to sign into your service (possibly because you don't require them to log in with their Google account to your service, so you can't require Google Sign In), then you will need to provide account linking through an OAuth server. There are many different ways to handle this:

    • If you already have an OAuth server - fantastic! You're good to go.

    • If you don't, you may want to look into something like Auth0 or IdentityServer to see if they meet your needs.

    • Finally, Google has also given instructions about creating your own OAuth server which will work with the Assistant. You can do this using the same platform you're building your webhook fulfillment on (for example, Firebase Hosting and Firebase Cloud Functions). Again, you won't find much sample code for this because each person's needs are different, but this provides some pseudo-code to discuss what you will need to implement.

Upvotes: 1

Related Questions