Skip to content

Commit 5893d76

Browse files
committed
match js sdk behavior in getAccessToken:
"Returns the current token if it has not expired or if it will not expire in the next five minutes. Otherwise, this will refresh the token and return a new one."
1 parent 0ffe5cd commit 5893d76

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.1.1
1+
version=0.1.2

src/main/java/com/google/firebase/auth/FirebaseAuth.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
243243
val source = TaskCompletionSource<GetTokenResult>()
244244
val user = user ?: return Tasks.forException(FirebaseNoSignedInUserException("Please sign in before trying to get a token."))
245245

246-
if (!forceRefresh || user.createdAt + user.expiresIn * 1000 * 0.90 > System.currentTimeMillis()) {
246+
if (!forceRefresh && user.createdAt + user.expiresIn - 5*60 > System.currentTimeMillis() / 1000) {
247247
// Log.i("FirebaseAuth", "returning existing token for user ${user.uid} from getAccessToken")
248248
return Tasks.forResult(GetTokenResult(user.idToken, user.claims))
249249
}

0 commit comments

Comments
 (0)