Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

271
Views
How do I receive the context parameter in the a cloud function onCall?

I have a cloud function that is called by my front-side app in React Native. Here is my cloud function:

exports.listProducts = functions.https.onCall((temp, context) => {
  console.log("fired");
  return context;
});

And here is how I call the function:

    let temp = await functions().httpsCallable("listProducts")(
      null,
      firebase.auth().currentUser
    );

However, I can't acccess the context variable in my cloud function which according to docs should be the Firebase auth. And the console.log in that function does not give me a log.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Any parameters you pass to the callable function are available in the first parameter, which you call temp, but that the Firebase documentation refers to as data.

You don't need to pass the current user to the callable function yourself, as the Firebase SDK already handles that for you, and the server already decoded the current user into context.auth.

For more on both parameters and the auth context, have a look at the Firebase documentation on writing and deploying callable functions, which contains:

Use functions.https.onCall to create an HTTPS callable function. This method takes two parameters: data, and optional context:

// Saves a message to the Firebase Realtime Database but sanitizes the text by removing swearwords.
exports.addMessage = functions.https.onCall((data, context) => {
 // ...
});

For a callable function that saves a text message to the Realtime Database, for example, data could contain the message text, while context parameters represent user auth information:

// Message text passed from the client.
const text = data.text;
// Authentication / user information is automatically added to the request.
const uid = context.auth.uid;
const name = context.auth.token.name || null;
const picture = context.auth.token.picture || null;
const email = context.auth.token.email || null;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!