Mike Dyer
Mike Dyer

Reputation: 33

How to pass a user's password to puppeteer inside a Firebase callable function?

How do I pass in a user's email & password into a function from a Firebase callable function?

I have written a callable function that uses puppeteer to navigate to a user's dashboard page, make a PDF of it, and then store the PDF in Cloud Storage.

My problem is that users must be authenticated to view the page. Without providing authentication, puppeteer just takes a PDF of my login page.

If I hard code in an email and password and toss it to puppeteer like so, then I get the desired dashboard page:

const page = await browser.newPage();

  

  await page.goto("https:www.somepage.com/auth/signin", {
    waitUntil: "networkidle2",
  });

  email = context.auth.token.email;
  password = "myPassword";


  await page.type("[type=email]", email);
  await page.type("[type=password]", password);
  await page.click("[type=submit");

  await page.waitFor(5000);

  await page.goto("https:www.somepage.com/dashboard", {
    waitUntil: "networkidle2",
  });

I know how to retrieve the current user's email from context, but how do I retrieve the password as well? Is this even possible?

Or, is there a better way to go about this altogether?

I've tried using context and admin, but have read that this is the wrong approach or just plain not possible.

Thank you for any help you can provide and sorry if this question has been answered elsewhere.

Upvotes: 2

Views: 455

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317758

It's not possible to get a users plaintext, unhashed password from Firebase Auth. That's considered a security problem.

Upvotes: 2

Related Questions