title: "Cannot read property 'uid' of undefined" error - Plaid link token
body: <p>I'm getting a &quot;Cannot read property 'uid' of undefined&quot; when trying to create a plaid token....I have spent like 3 days trying to make it work.</p>
  <p><strong>does anybody knows how to fix it?</strong></p>
  <p><a href="https://i.stack.imgur.com/zKCy5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zKCy5.png" alt="enter image description here" /></a>
  Cloud function to get Plaid token</p>
  <pre><code>//PLAID - create link Token plaid Nat
  const plaid = require(&quot;plaid&quot;);
  
  exports.createPlaidLinkToken = functions.https.onCall(async (data, context) =&gt; {
    const customerId = context.auth.uid;
  
    const plaidClient = new plaid.Client({
      clientID: functions.config().plaid.client_id,
      secret: functions.config().plaid.secret,
      env: plaid.environments.development,
      options: {
        version: &quot;2019-05-29&quot;,
      },
    });
  
    return plaidClient.createLinkToken({
        user: {
          client_user_id: customerId,
        },
        client_name: &quot;Reny&quot;,
        products: [&quot;auth&quot;],
        country_codes: [&quot;US&quot;],
        language: &quot;en&quot;,
      })
      .then((apiResponse) =&gt; {
        const linkToken = apiResponse.link_token;
        return linkToken;
      })
      .catch((err) =&gt; {
        console.log(err);
        throw new functions.https.HttpsError(
          &quot;internal&quot;,
          &quot; Unable to create plaid link token: &quot; + err
        );
      });
  });
  </code></pre>
  <p>swift function</p>
  <pre><code>    class func createLinkToken(completion: @escaping (String?) -&gt; ()){
          //this is the firebase function
          Functions.functions().httpsCallable(&quot;createPlaidLinkToken&quot;).call { (result, error) in
              if let error = error {
                  debugPrint(error.localizedDescription)
                  return completion(nil)
              }
              guard let linkToken = result?.data as? String else {
                  return completion(nil)
              }
              completion(linkToken)
          }
      }
  
  </code></pre>