在 Google App Engine 上验证 Firebase 令牌 [英] Verify Firebase Token at Google App Engine

查看:21
本文介绍了在 Google App Engine 上验证 Firebase 令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Google App Engine 开发应用程序.我正在使用 Cloud Endpoints 在我的 Google App Engine 后端的 Android 应用程序之间进行通信.Android 客户端使用 Firebase 身份验证并在每次调用时向 Cloud Endpoints 发送 Firebase 令牌.

I am developing an Application at Google App Engine. I am using Cloud Endpoints for the communication between an Android App at my Backend at Google App Engine. The Android client uses Firebase Authentication and sends with every call the Firebase token the Cloud Endpoints.

在 Google App Engine 中,我使用以下代码来验证 Firebase 令牌.我正在使用 Firebase Admin SDK 4.0.3

At Google App Engine I use the following code to verify the Firebase Token. I am using the Firebase Admin SDK 4.0.3

Task<FirebaseToken> authTask = FirebaseAuth.getInstance().verifyIdToken(token);

try {
    Tasks.await(authTask);
} catch (ExecutionException | InterruptedException e ) {
    log.severe(e.getMessage());
}
FirebaseToken decodedToken = authTask.getResult();

任务的执行正在 Google App Engine 后端任务中运行,但不幸的是,此后端实例并未关闭,因此我超出了我的免费配额限制.那么有人可以给我一个提示,我如何在令牌验证后关闭后端实例?

The execution of the Task is running at a Google App Engine Backend Task but unfortunately this Backend instance does not shutdown and so I exceed my free quota limit. So can someone give me a hint how I can shutdown the Backend Instance after Token verfication?

推荐答案

这是 Firebase Admin Java SDK 的一个已知问题,实际上是我们难以修复的错误.暂时唯一的解决方法是使用更新版本的 SDK (>= 4.0.4),该版本支持在前端实例中使用此方法(在处理后完全关闭).

This is a known issue with the Firebase Admin Java SDK and is actually a difficult bug for us to fix. The only workaround for the time being is to use a more recent version of the SDK (>= 4.0.4) which supports using this method in frontend instances (that shutdown cleanly after processing).

不幸的是,在一个单独的问题中,verifyIdToken() 方法在 4.1.0 版本中由于依赖不良而被破坏.因此,您必须使用 4.0.4 或 >= 4.1.1.

Unfortunately, in a separate issue, the verifyIdToken() method is broken in the 4.1.0 release due to a bad dependency. So, you'll have to use either 4.0.4 or >= 4.1.1.

抱歉给大家带来的麻烦!我们将尽快修复 verifyIdToken() 方法.与此同时,4.0.4 版本应该适合你.

Sorry for all the troubles! We will get the verifyIdToken() method fixed ASAP. In the meantime, version 4.0.4 should work for you.

更新

verifyIdToken() 方法的第二个较小的问题已在 管理 Java SDK 4.1.1 版.

The second, smaller issue with the verifyIdToken() method was fixed in version 4.1.1 of the Admin Java SDK.

这篇关于在 Google App Engine 上验证 Firebase 令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆