Google Identity Toolkit API 400 Error after many successful sign-ins

42 Views Asked by At

I have a Firebase Function that verifies if requests are from an authorized user with Google Identity Toolkit's signInWithPassword endpoint. The vast majority of the time this works fine. However, when requests, and therefore sign-in attempts, are received frequently (a request every 5 seconds for 10 minutes) it will start returning a 400 'ERR_BAD_REQUEST'. Sometimes it breaks down gradually - a fail, then succeed on a retry, then fail repeatedly. Sometimes it goes straight to failing repeatedly. Sometimes it gets through the 10 minutes of sign-ins fine, though rarely. These frequent sign-ins are for the same user. The sign-in code:

const signIn = {
    url: 'https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=abc123',
    data: {
        email: email,
        password: pass,
        returnSecureToken: true,
    },
    config: {
        headers: {
            'Content-Type': 'application/json',
        },
    },
};
const authRes = await axios.post(signIn.url, signIn.data, signIn.config);
0

There are 0 best solutions below