Getting Google user ID in Node.js in Firebase for Assistant app

I started working with the Google cloud platform.

I am developing an Android application that will collect information and store it in a Firebase application. The idea is that the Google Assistant function can request this information and read it back, for example

OK Google Talk To Simons App, tell me when XYZ was last run

However, the problem is to make it multi-user.

I have an Android app that collects data and puts it in the cloud. I use FirebaseUserand using getUid()in an Android application to get a unique identifier, which is a string with 28 characters, for example uVHkia8RRgWD8GGPVvW4AUDUK2.

I installed actions on Google, ran it in the API.AI using Web Fulfillment, and got Node.js working in firebase functions.

Unfortunately, UserIDI come back more like:HTge48H0CF2FC5jJQCigFBc-UCQ

The problem is that this one UserIDdoes not match the UserUIDone I received from the Filebase user.

Im using

let ApiAiApp = require('actions-on-google').ApiAiApp;
const app = new ApiAiApp({request: request, response: response});

and

const userId = app.getUser().userId;

What am I missing? I see links to OAuth2, Link Linking, etc. I'm not quite sure what to do at the moment. All I need to do at the moment is to get User UIDhow I get from FirebaseUser.getUID()to view the data in the Firebase database.

I think the rest should be straightforward.

Firebase , . , , / API.AI "". , , , .

+4
1

, app.getUser().userId, . cookie, -, - , , , .

, , , Link Linking, OAuth2. :

  • - . URL- Google . , , , URL- . - Firebase . URL- auth ( ) .

  • . Google URL . , , , . ( , Google , .)

  • auth -. API.AI webhook, . , Firebase .

, auth, - , - / Firebase. :

  • / JSON Web Token (JWT). Firebase , , . , , , . JWT, , , , .

  • Firebase. , , .

OAuth . . https://developers.google.com/actions/identity/oauth2-code-flow.

+2

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


All Articles