Skip to content

Commit

Permalink
fix OKHttp response fail: java.lang.IllegalStateException: closed
Browse files Browse the repository at this point in the history
  • Loading branch information
nbransby committed Jul 9, 2024
1 parent 3f59ec4 commit d6caac7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.4.3
version=0.4.4
29 changes: 14 additions & 15 deletions src/main/java/com/google/firebase/auth/FirebaseAuth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -348,21 +348,20 @@ class FirebaseAuth constructor(val app: FirebaseApp) : InternalAuthProvider {

@Throws(IOException::class)
override fun onResponse(call: Call, response: Response) {
response.body().use { body ->
if (!response.isSuccessful) {
signOutAndThrowInvalidUserException(body?.string().orEmpty(), "token API returned an error: ${body?.string()}")
} else {
jsonParser.parseToJsonElement(body!!.string()).jsonObject.apply {
val user = FirebaseUserImpl(app, this, user.isAnonymous)
if (user.claims["aud"] != app.options.projectId) {
signOutAndThrowInvalidUserException(
user.claims.toString(),
"Project ID's do not match ${user.claims["aud"]} != ${app.options.projectId}"
)
} else {
this@FirebaseAuth.user = user
source.setResult(user)
}
val body = response.body()?.use { it.string() }
if (!response.isSuccessful) {
signOutAndThrowInvalidUserException(body.orEmpty(), "token API returned an error: $body")
} else {
jsonParser.parseToJsonElement(body!!).jsonObject.apply {
val user = FirebaseUserImpl(app, this, user.isAnonymous)
if (user.claims["aud"] != app.options.projectId) {
signOutAndThrowInvalidUserException(
user.claims.toString(),
"Project ID's do not match ${user.claims["aud"]} != ${app.options.projectId}"
)
} else {
this@FirebaseAuth.user = user
source.setResult(user)
}
}
}
Expand Down

0 comments on commit d6caac7

Please sign in to comment.