firebase-tools: `firebase auth:export` doesn't include provider info for Apple Sign In

[REQUIRED] Environment info

firebase-tools: 9.11.0

Platform: macOS (M1)

[REQUIRED] Test case

I can’t provide a test case, because I would need to give you access to my Firebase project.

[REQUIRED] Steps to reproduce

  1. Set up a Firebase project
  2. Enable “Apple Sign In” for Firebase Auth
  3. Use Sign In with Apple with a user
  4. Run firebase auth:export auth_export.json
  5. Open auth_export.json

[REQUIRED] Expected behavior

I would expect that the provider info also be export like:

{
  "localId": "0YPO0atCUVaeP8gTIZVDn4oZxIZ2",
  "email": "myaccount@icloud.com",
  "emailVerified": true,
  "lastSignedInAt": "1621582693401",
  "createdAt": "1621582693401",
  "providerUserInfo": [
   {
      "providerId": "apple.com",
      "rawId": "rawId",
      "email": "myaccount@icloud.com",
      "displayName": "MyName",
    }
  ]
},

If you import this data, the user should have an Apple provider: Screenshot 2021-05-25 at 00 02 00

[REQUIRED] Actual behavior

{
  "localId": "0YPO0atCUVaeP8gTIZVDn4oZxIZ2",
  "email": "myaccount@icloud.com",
  "emailVerified": true,
  "lastSignedInAt": "1621582693401",
  "createdAt": "1621582693401",
  "providerUserInfo": [] // <----- Why is this empty???
},

If you import this data, the use will not have a provider: Screenshot 2021-05-25 at 00 00 07

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 10
  • Comments: 19 (3 by maintainers)

Most upvoted comments

Made some progress on this locally. Cloned firebase-tools and made the following changes:

  1. in src/accountExporter, add "apple.com": 23 to the PROVIDER_ID_INDEX_MAP (I think you can just assign any number in increments of 4)
  2. in src/accountImporter, add "apple.com" to ALLOWED_PROVIDER_IDS
  3. in src/accountImporter, add _addProviderUserInfo(user, "apple.com", arr.slice(23, 27)); below the other _addProviderUserInfo calls (lines up with the ID index map from accountExporter)

It exports the providerUserInfo correctly i.e.

"providerUserInfo": [
    {
      "providerId": "apple.com",
      "rawId": "........",
      "email": "........."
    }
  ]

This caused a suppressed localId is missing error on import, so I had to swap out const user = validateUserJson(value); for const user = value in auth-import.ts. If you took some time, you could probably figure out why the validateUserJson function was returning {} instead of the user data.

Anyway, successfully imported all my apple-auth’ed users.

Hi, thanks for filing this issue! We are unable to promise any timeline for this, but if others also have this issue, adding a thumbs up on this issue can help us prioritize adding this to the roadmap.

(Googler-only internal tracking bug: b/240348641)

Hi @lisajian, it’s great to see that this issue got some attention ❤️ However, it’s for me unclear why the Firebase hasn’t fixed this issue after 2 year (after adding Apple as new sign in provider). Exporting the Firebase Auth user is essential for every production app. How should you do your backups without exporting all users? Issues like this should be a red flag for every company for using Firebase in production because good backups are necessary for production apps.

Totally understand your concern and we’re working on triaging the issue internally. While this is getting addressed, please take a look at the other ways of exporting and importing users, e.g. Admin SDK’s listUsers() for exporting and createUser() for importing, or you can hit the underlying endpoints directly by calling batchGet for exporting and batchCreate for importing. These will return up to date user info, including Apple as a sign in provider.