question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

auth/internal-error calling `generateEmailVerificationLink` or `generatePasswordResetLink`

See original GitHub issue

Describe your environment

  • Operating System version: Firebase Functions Environment
  • Firebase SDK version: 7.0.0
  • Library version: 7.0.0
  • Firebase Product: auth

Describe the problem

I’m facing internal-error when calling the auth functions to generate Email verification link or password verification link. It throws the error randomly, some time it is successful, but its not consistent. There is no rate limit mentioned for the functions generateEmailVerificationLink and generatePasswordResetLink. Other operations of auth like getUser and setCustomClaims works fine in the same execution where the above mention two functions are failing. The complete error response is: {"error":{"code":400,"message":"TOO_MANY_ATTEMPTS_TRY_LATER","errors":[{"message":"TOO_MANY_ATTEMPTS_TRY_LATER","domain":"global","reason":"invalid"}]}}

Steps to reproduce:

The below code captures the flow of auth operation executions in my application.

Relevant Code:

let promises = [];
let auth = admin.auth();
let hrstart = process.hrtime();


async function testAuth(i) {
    let email = `email+test${i}@gmail.com`;
    let user;
    try {
        user = await auth.createUser({email, password: 'password1234567890'});
    } catch (e) {
        console.log('error creating user', email, e);
        // return Promise.reject(e);
    }

    try {
        await auth.setCustomUserClaims(user.uid, {abc: `testwqa`});
    } catch (e) {
        console.log('error writing user claims', email, e);
        // return Promise.reject(e);
    }

    try {
        user = await auth.getUser(user.uid);
    } catch (e) {
        console.log('error reading user ', email, user.uid, e);
        // return Promise.reject(e);
    }

    let link, plink;
    try {
        link = await auth.generateEmailVerificationLink(user.email, {url: `https://${projectId}.firebaseapp.com/redeem-reward`});
    } catch (e) {
        console.log('error generating email link for ', user.uid, e);
        // return Promise.reject(e);
    }

    try {
        plink = await auth.generatePasswordResetLink(user.email, {url: `https://${projectId}.firebaseapp.com/redeem-reward`});
    } catch (e) {
        console.log('error generating password link for ', user.uid, e);
        // return Promise.reject(e);
    }


    return {user, link, plink};
}

for (let i = 0; i < 3; i++) {
    promises.push(testAuth(i));
}

Promise.all(promises)
    .then(value => {
        let hrend = process.hrtime(hrstart);
        console.log(hrend);
        console.log(value)
    });

Error log: image

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:27 (8 by maintainers)

github_iconTop GitHub Comments

7reactions
timshirleycommented, May 10, 2021

One thing to ensure if you’re running into this is that you’re not using the same email address across multiple attempts. I found through experimentation that it will only allow a link to be generated once per minute per email address… Which seems a perfectly reasonable thing to do to avoid spamming someone, but should still be mentioned in the limits documentation. I do not see this issue if I switch addresses between attempts.

5reactions
MihirSomanicommented, Feb 1, 2021

After spending 10+ hours trying to resolve this issue of getting rate limited on the 2nd query, I’ve had to completely remove Firebase Email Verification from my codebase. This just shows how limited platforms like Firebase are for production grade environments.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generating Email Action Links | Firebase Authentication
Generate email verification link. To generate an email verification link, provide the existing user's unverified email and an optional ActionCodeSettings object ...
Read more >
admin only operation firebase error - You.com | The AI Search ...
Describe the problem. I'm facing internal-error when calling the auth functions to generate Email verification link or password verification link. It throws the ......
Read more >
"admin.auth(...).generatePasswordResetLink is not a function ...
You are most probably using a version of the Node.js Admin SDK that is < Version 6.2.0. See the Firebase Admin Node.js SDK...
Read more >
Generating email action links using the Firebase Admin SDK
This API, and others like it, make RPC calls to the Firebase Auth service, ... generateEmailVerificationLink(); generatePasswordResetLink ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found