Skip to content

Commit

Permalink
match js sdk behavior in getAccessToken:
Browse files Browse the repository at this point in the history
"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."
  • Loading branch information
nbransby committed Oct 3, 2023
1 parent 0ffe5cd commit 5893d76
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.1.1
version=0.1.2
2 changes: 1 addition & 1 deletion src/main/java/com/google/firebase/auth/FirebaseAuth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {
val source = TaskCompletionSource<GetTokenResult>()
val user = user ?: return Tasks.forException(FirebaseNoSignedInUserException("Please sign in before trying to get a token."))

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

0 comments on commit 5893d76

Please sign in to comment.