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

267
Views
firebase (v9) How to get 'isNewUser' info after Google redirect?

I would like to check if the user is new after a Google redirect. Inside the signInWithEmailLink routine this works

let credential = await signInWithEmailLink(auth, email, window.location.href)
const details = getAdditionalUserInfo(credential)
const isNewUser = details.isNewUser

but logging this credential gives UserCredentialImpl and the credential after the redirect OAuthCredential
So this doesn't work

 const redirectResult = await getRedirectResult(auth)
        if(redirectResult) {
            try {
                const credential = GoogleAuthProvider.credentialFromResult(redirectResult);
                console.log('credential', credential)
                const details = getAdditionalUserInfo(credential)
                const isNewUser = details.isNewUser           
            } catch (error) {
                const email = error.email;
                const credential = GoogleAuthProvider.credentialFromError(error);
                console.log('error while signing in with google - getting redirect result', email, credential, error)
            }
        }

with the IDE already complaining "Argument type OAuthCredential is not assignable to parameter type UserCredential" and the error "TypeError: Cannot read properties of undefined (reading 'isAnonymous')"

How can the .isNewUser info be read after the redirect?

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

0

I just realized that the redirectResult is of type UserCredentialImpl so this works

const redirectResult = await getRedirectResult(auth)
        if(redirectResult) {
            try {      
                const details = getAdditionalUserInfo(redirectResult)
                const isNewUser = details.isNewUser
                ...           
            } catch (error) {
                ...
            }
        }

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!