Razvan Cristian Lung
Razvan Cristian Lung

Reputation: 6071

Firebase functions get the user phone number

I'm using Firebase Function to save the user info in onCreate, using auth trigger. Is there a way to get the users phone number if he authenticated using this method?

Upvotes: 2

Views: 3129

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599571

As shown on the Functions Github repo:

Phone Auth now triggers Cloud Functions, as intended. Here's an example of the UserRecord object (in event.data) that you might receive:

{
  "metadata": {
    "createdAt": "2017-06-01T23:01:23.000Z",
    "lastSignedInAt": "2017-06-01T23:01:23.000Z"
  },
  "phoneNumber": "+1555123456",
  "providerData": [
    {
      "providerId": "phone",
      "uid": "+1555123456"
    }
  ],
  "uid": "C6simWCCNlO3Mdyq9PYyY1O8qPJ3"
}

The phone number is then available from the UserRecord.phoneNumber

Upvotes: 5

Related Questions