Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the current user id using firebase admin?

I am working on an assistant app for which I am writing a cloud function which must retrieve the current user data from Firebase database by using the user id. I am using firebase admin and I referred the docs for firebase admin where they've mentioned the way of retrieving user data by using user id but they haven't mentioned how to get the current user id. How do I get the currently signed in user id?

like image 640
Mustafa Bhatkar Avatar asked Oct 17 '22 08:10

Mustafa Bhatkar


1 Answers

In order to get currently signed user id, you need to enable Account Linking in your AoG app.

In your AoG settings, enable Account linking with authorization code as grant type. Fill your client information and choose scopes.

Now when a user uses your app, it will ask for sign in, and on your AoG backend, you will be able to get authorization code.

Now using that authorization code you can retrieve the required user id and use that for your firebase admin.

You can find more info for Account linking here.

like image 165
J Shubham Avatar answered Oct 21 '22 00:10

J Shubham