title: Firebase: how to get getAdditionalUserInfo in onCreate Firebase Cloud function
body: <p>I'm trying to get some additional data from a SAML login provider. I can see this data in the client but I fail to see how to get this in the back end (firebase functions).</p>
  <p>I'm using these in the FE</p>
  <pre><code>&quot;firebase&quot;: &quot;^9.8.2&quot;,
  &quot;firebase-functions&quot;: &quot;^3.14.1&quot;,
  </code></pre>
  <p>And this in the BE</p>
  <pre><code>&quot;firebase-admin&quot;: &quot;^10.2.0&quot;,
  &quot;firebase-functions&quot;: &quot;^3.21.2&quot;,
  </code></pre>
  <p>This is the data and how I get it in the client:</p>
  <pre><code>async myproviderSignIn() {
    const provider = new SAMLAuthProvider('saml.myprovider');
    const auth = getAuth();
  
    const userCredential = await signInWithPopup(auth, provider);
    const credential = SAMLAuthProvider.credentialFromResult(userCredential);
  
    if (!environment.production) {
      console.log('User:', userCredential, credential);
      console.log(
        'getAdditionalUserInfo:',
        getAdditionalUserInfo(userCredential)
      );
    }
  }
  </code></pre>
  <p>This is what I'm after and logged by getAdditionalUserInfo in the client:</p>
  <pre><code>{
      &quot;isNewUser&quot;: false,
      &quot;providerId&quot;: &quot;saml.myprovider&quot;,
      &quot;profile&quot;: {
          &quot;urn:schac:attribute-def:schacPersonalUniqueCode&quot;: &quot;urn:schac:personalUniqueCode:nl:local:diy.myproviderconext.nl:studentid:123456&quot;,
          &quot;urn:oid:1.3.6.1.4.1.25178.1.2.9&quot;: &quot;diy.myproviderconext.nl&quot;,
          &quot;urn:oid:1.3.6.1.4.1.25178.1.2.14&quot;: &quot;urn:schac:personalUniqueCode:nl:local:diy.myproviderconext.nl:studentid:123456&quot;,
          &quot;urn:oid:0.9.2342.19200300.100.1.3&quot;: &quot;student1@diy.myproviderconext.nl&quot;,
          &quot;urn:oid:1.3.6.1.4.1.5923.1.1.1.1&quot;: [
              &quot;student&quot;,
              &quot;employee&quot;,
              &quot;staff&quot;,
              &quot;member&quot;
          ],
          &quot;urn:mace:dir:attribute-def:eduPersonAffiliation&quot;: [
              &quot;student&quot;,
              &quot;employee&quot;,
              &quot;staff&quot;,
              &quot;member&quot;
          ],
          &quot;urn:mace:dir:attribute-def:sn&quot;: &quot;One&quot;,
          &quot;urn:mace:dir:attribute-def:givenName&quot;: &quot;Student&quot;,
          &quot;urn:oid:2.5.4.42&quot;: &quot;Student&quot;,
          &quot;urn:mace:dir:attribute-def:mail&quot;: &quot;student1@diy.myproviderconext.nl&quot;,
          &quot;urn:oid:2.5.4.4&quot;: &quot;One&quot;,
          &quot;urn:mace:terena.org:attribute-def:schacHomeOrganization&quot;: &quot;diy.myproviderconext.nl&quot;
      }
  }
  </code></pre>
  <p>Finally this is my BE on user create trigger. It creates a DB record of the user when a new user is created in Firebase auth. I'd wish to map some of the properties shown above here to the user record in the DB.</p>
  <pre><code>export const onCreate = functions.auth
    .user()
    .onCreate((user: UserRecord, context: EventContext) =&gt; {
      const timestamp = serverTimestamp();
  
      const dbUser: DbUser = {
        uid: user.uid,
        name: user.displayName || '',
        firstName: user.displayName || '',
        lastName: '',
        email: user.email,
        photoURL: user.photoURL,
        emailVerified: user.emailVerified,
        createdDate: timestamp,
        lastSeen: timestamp,
        providerData: JSON.parse(JSON.stringify(user.providerData)),
        userDump: JSON.parse(JSON.stringify(user)),
        contextDump: JSON.parse(JSON.stringify(context)),
      };
  
      // Get additional user data from the UserCredential
      // const additionalUserInfo = getAdditionalUserInfo(user); ???
  
      const result = getFirestore()
        .collection(constants.dbCollections.users)
        .doc(user.uid)
        .set(dbUser);
  
      return result;
    });
  </code></pre>
  <p><strong>How do I access these additional properties in my cloud function without relying on the client?</strong></p>