Arkangel
01/07/2021, 3:17 PMJorge R
01/08/2021, 9:50 AMGoogleIdTokenVerifier
? I’ve implemented in my app Sign In with Google, if that is what you are asking about.Arkangel
01/08/2021, 1:17 PMclass AuthenticationControllerImpl : AuthenticationController {
override suspend fun authenticate(token: String?): TaskResult<Boolean> {
if (isInTestMode) {
return TaskResult.Success(true)
}
return try {
var authorizationHeader = token?.replace("Bearer", "")?.replace(" ", "")
var jwt = JWT.decode(authorizationHeader)
FirebaseAuth.getInstance().verifyIdToken(jwt.token)
TaskResult.Success(true)
} catch (exception: Exception) {
return TaskResult.Error(
AuthenticationException("Not Authorized")
)
}
}
}
interface AuthenticationController {
suspend fun authenticate(token: String?): TaskResult<Boolean>
}
Jorge R
01/10/2021, 12:18 AMArkangel
01/11/2021, 2:40 PMLaurence
01/19/2021, 10:06 AMArkangel
01/19/2021, 10:07 AMJorge R
01/19/2021, 10:36 AMonNewToken()
method in your device, so you will need to sync it with your device local storage anyway. But the entrypoint will be at device level, it is the one that will trigger the calls.
With what Laurence posted here, you can just delegate to device everything related with token, and all the authenticated calls in your API should contain a firebase token that will be validated by Firebase authenticator.