aryaxt
aryaxt

Reputation: 77626

Firebase HTTP function accessing userID?

Couple of questions about firebase functions.

I have a function that needs to verify that the current user is authenticated, and then use their userId to store some data and associate it to them.

Upvotes: 1

Views: 219

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317692

To get started, look at the official sample code available in GitHub that shows how to protect an endpoint. You'll see that it takes a token from Firebase Authentication for the currently authenticated user using getIdTokenWithCompletion. The function uses the Firebase Admin SDK to verify the token. The result of verification is a DecodedIdToken object, which contains various properties, including the user's uid.

Upvotes: 1

Related Questions