Setting providerData in auth.createUser (custom auth system)

728 views
Skip to first unread message

Alan deLespinasse

unread,
Mar 25, 2017, 10:16:09 PM3/25/17
to Firebase Google Group
I've so far been using firebaseui-web to allow users to sign in to my web app using email, Google, or Facebook. It works great. I didn't have to understand the auth system very well to use it.

Now I'm trying to allow them to sign in with Slack if they want. It's mostly working, but when the user logs in, currentUser.providerData is an empty array. I'm trying to set it when I create the user with firebase.auth().createUser() (on the server side, using firebase-admin), but whatever data I set for providerData is ignored.

I'm actually using providerData to track how many users sign in with different providers, so it would be nice if I could set it for new custom providers. Is there any way to do this? I can come up with a workaround if not, but it will be annoying.

This question on Stack Overflow looks like it might be the same question, but it's marked as a duplicate, and the linked answer doesn't seem to answer my question (it's about custom token claims).

Kato Richardson

unread,
Apr 13, 2017, 3:28:33 PM4/13/17
to Firebase Google Group
Hi Alan,

I don't think you can override providerData or anything that's available in the client SDK. I could be wrong here, but I'm pretty sure the claims in the JWT token are only available in security rules.

Instead, I think you should write meta data to the DB or another resource and then the client, once authenticated with the uid you've assigned, can look it up there.

☼, Kato

Note that the simplest answer here is to have whatever 

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/d87e68d9-58bb-443e-bbbc-faaa9e5f7119%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Alan deLespinasse

unread,
Apr 23, 2017, 11:48:11 AM4/23/17
to Firebase Google Group
Yeah, that's pretty much what I'm doing. I'm just surprised, because I didn't expect the built-in sign-in methods to have that much special privilege over custom methods.

Also, it seems like it would be useful to let custom methods set provider data (or even to require them to), for symmetry, and for components that expect it. For example, FirebaseUI-web can't show a good error message if someone tries to log in using an email address that is already linked to an account made with a custom sign-in method: https://github.com/firebase/firebaseui-web/issues/134


On Thursday, April 13, 2017 at 3:28:33 PM UTC-4, Kato Richardson wrote:
Hi Alan,

I don't think you can override providerData or anything that's available in the client SDK. I could be wrong here, but I'm pretty sure the claims in the JWT token are only available in security rules.

Instead, I think you should write meta data to the DB or another resource and then the client, once authenticated with the uid you've assigned, can look it up there.

☼, Kato

Note that the simplest answer here is to have whatever 
On Sat, Mar 25, 2017 at 7:16 PM, Alan deLespinasse <adeles...@gmail.com> wrote:
I've so far been using firebaseui-web to allow users to sign in to my web app using email, Google, or Facebook. It works great. I didn't have to understand the auth system very well to use it.

Now I'm trying to allow them to sign in with Slack if they want. It's mostly working, but when the user logs in, currentUser.providerData is an empty array. I'm trying to set it when I create the user with firebase.auth().createUser() (on the server side, using firebase-admin), but whatever data I set for providerData is ignored.

I'm actually using providerData to track how many users sign in with different providers, so it would be nice if I could set it for new custom providers. Is there any way to do this? I can come up with a workaround if not, but it will be annoying.

This question on Stack Overflow looks like it might be the same question, but it's marked as a duplicate, and the linked answer doesn't seem to answer my question (it's about custom token claims).

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/d87e68d9-58bb-443e-bbbc-faaa9e5f7119%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages