How do I set displayName in Firebase when using Apple authentication?

1.8k views Asked by At

I am trying to use Apple OAuth on the web with the Firebase Javascript SDK, and when I do, the returned user object is fine, except for displayName, which is null.

  let provider = new firebase.auth.OAuthProvider("apple.com");
  provider.addScope("email");
  provider.addScope("name");
  let userCred = await firebase.auth().signInWithPopup(provider);

However when I look at the userCred I get:

displayName: null

I tried the scope fullName to no luck.

Is there any way to get the display name? I use it so that my users can see their name on the site, to personalize the experience.

1

There are 1 answers

0
nullUser On

You get this right on the response to appleAuth signin response

const appleAuthRequestResponse = await appleAuth.performRequest({
      requestedOperation: appleAuth.Operation.LOGIN,
      requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME]
    });

appleAuthRequestResponse will hold the name details.

Please note that, if you had already used your account for testing, you will have to login to your appleid and remove the apple sign in for your app, to test this.[ Also delete this user from firebase auth ]