Skip to content

Firebase Auth w/Provider: Calling getRedirectResult() always returns NULL user #3115

@rmcsharry

Description

@rmcsharry

[REQUIRED] Describe your environment

  • Operating System version: MacOS 10.15.3___
  • Browser version: __Chrome Version 81.0.4044.138 ___
  • Firebase SDK version: 7.13.1
  • Firebase Product: _auth (auth, database, storage, etc)

[REQUIRED] Describe the problem

Steps to reproduce:

After calling signInWithRedirect() and then getRedirectResults() on the page load after the login succeeds, the user is always null.

This has been reported before here but was closed.

Relevant Code:

This code runs on page load, but the user is null:

  firebase.auth().getRedirectResult().then(credential => {
    if (credential.user)
      firebase
        .database()
        .ref('users')
        .child(credential.user.uid)
        .child('email')
        .set('[email protected]');
  });

However, in onAuthStateChanged there is a user.

https://stackoverflow.com/questions/62032646/firebase-realtime-database-rules-to-restrict-on-user-id-runs-in-simulator-but-no/62040506#62040506

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions