Actions with a Google + account associated with Firebase

I am working on a Google home application using an external API. I need a current user to log in and associated with an external API (access / update token provided by an external API).

My approach:

  • Configure firebase application
  • The google home application is located in the functions folder.
  • I would set up a page where the user first had to log in to his Google account using firebase.auth () , then his external API (using the external Oauth API).
  • Then I created an entry in the firebase database to store for each user the access / update token provided by the external API.

That's where I got a little confused and stuck. I managed to set up a login page (Google login, then external API login) and save the firebase database (/ users / {google_uid}).

Now that it’s in the database, how do I configure authentication in the Google home application?

Thanks!

+4
firebase firebase-authentication actions-on-google
source share
2 answers

First you need to have a project in console.developers.google.com and activate the Google Actions API in your project. Then follow these steps:

  • Rename the following redirect URL to the URI: https://oauth-redirect.googleusercontent.com/r/

  • In the API.AI project, go to the Integration section and turn on the Google Card.

  • In the Actions settings in Google, put your project identifier and select Sign mandatory for welcome intent and any others so that users need credentials. enter image description here

  • Below you will find OAuth2 fields such as clientID, client secret, authorization URL and token. Follow it with OAuth2 information about your API and Authorize application. enter image description here

After authorization, you can Preview the application, and it will be available on your Google Home device, and upon the first call, it will provide a map in your Google Home application. make a link. If you don’t have a device, there is a web simulator where you can test your action.

For more information, see the documents in the Google documentation .

+3
source share

There are a few issues with how you think of an account associated with activities on Google and Google Home. Google Home does not give you direct access to your Google account — instead, it acts like a web browser, and the account build process requires you to issue the OAuth2 token in your “browser” at home so that it can use it in the future.

If you have control over the external API and it issues OAuth2 tokens (which looks like this), you can completely skip the Firebase part. You just need to configure the API.AI with OAuth2 information for this external service - client ID and secret, URL for the login page and token exchange page, etc. In this case, your web hosts will be called by providing OAUth2 an access token that you must pass to the external API when you call it. For more information, see the documentation for the "Actions for Google" Account documentation .

If you are not in control of this API, you may need to provide a basic OAuth2 server implementation that can issue authentication tokens (those that you create, or those that can be used to get auth tokens from an external API). Then your web sites will be called using these OAuth tokens, and you must use the token to find the token to access the external API. You have some options for implementing this, and these options are discussed in the OAuth2 Account Linking Overview in the Actions docs for Google.

+2
source share

All Articles