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.

AngularFireAuth idToken emits a string instead of User

See original GitHub issue

Hi there, thanks for a great library, I’ve been using it on a large-ish project for a year or so.

I recently upgraded Angular/AngularFire/Firebase in the project and struck an issue with the account creation flow that took me a little while to fathom. It all came down to the change of behaviour of authState in 4.0.0-rc0, due to the underlying change in Firebase’s onAuthStateChanged. After finding your changelog entry stating “The added AngularFireAuth.idToken: Observable<firebase.User> behaves as authState used to.” I tried using it, but found the signature did not match what I was expecting.

Also, I read your v4 upgrade guide but didn’t see any mention of the backward compatible idToken observable.

I have downgraded to AngularFire 5.0.0-rc.0 as a temporary workaround, to get latest version before idToken was altered.

Version info

Angular: 5.2.2

Firebase: 4.9.1

AngularFire: 5.0.0-rc.6

Other (e.g. Ionic/Cordova, Node, browser, operating system):

Expected behavior

idToken would be a drop-in replacement for users upgrading from pre-4.0.0 angularfire2’s authState, as described in the changelog

This makes sense as it follows the interface of the firebase library’s onIdTokenChanged which returns a nullable firebase.User

Actual behavior

idToken emits the result of the user.getIdToken promise to subscribers. This behaviour appears to have changed in this commit: https://github.com/angular/angularfire2/commit/8ab38037df901030b378e4e7d881677e65169be5

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
jamesdanielscommented, May 4, 2018

FYI We’re planning on adding .user which will expose the user from onIdTokenChanged

4reactions
jamesdanielscommented, May 16, 2018

Just cut rc.9, which includes the change

Read more comments on GitHub >

github_iconTop Results From Across the Web

AngularFireAuth idToken emits a string instead of User
I recently upgraded Angular/AngularFire/Firebase in the project and struck an issue with the account creation flow that took me a little while ...
Read more >
How do I get the current user's access token in AngularFire2?
You should use getIdToken instead: this.af.auth.currentUser.getIdToken(true) .then((token) => localStorage.setItem('tokenId', token));.
Read more >
angular/angularfire2 - Gitter
So my question is, is it possible to get an ID token for a user without logging that user in? I was hoping...
Read more >
Why is my currentUser == null in Firebase Auth? - Medium
Getting the currently signed in user with Firebase Authentication seems easy ... Check and load the persisted user ID token from disk.
Read more >
[Solved]-Angular - How to unify auth observable?-rx.js
Here is a version of your example that is modified to use BehaviorSubject . import { Injectable } from '@angular/core'; import { AngularFireAuth...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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