geek glance
geek glance

Reputation: 111

How to get firebase last auth token Refresh time

I want to get when did the token refreshed last time from firebase. How can I get that?

I have refered answer based on this post. But did not understand properly please help

Upvotes: 0

Views: 382

Answers (1)

Dharmaraj
Dharmaraj

Reputation: 50920

If you are using Javascript SDK you can use getIdTokenResult method and check for issuedAtTime. It is defined as "The ID token issued at time formatted as a UTC string." in the documentation.

const user = firebase.auth().currentUser

if (user) {
  user.getIdTokenResult().then((result) => {
    const {issuedAtTime, expirationTime} = result 
    console.log(`This token was issued at: ${issuedAtTime}`)
    console.log(`This token will expire at: ${expirationTime}`)
  })
}

Upvotes: 2

Related Questions