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

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

问题描述

我正在Google App Engine上开发一个应用程序。我正在使用Cloud Endpoints在Google App Engine的后端Android应用程序之间进行通信。 Android客户端使用Firebase身份验证,并随每次调用Firebase令牌一起发送Cloud Endpoints。

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

 任务< FirebaseToken> authTask = FirebaseAuth.getInstance()。verifyIdToken(token); 

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

任务的执行在Google App Engine后端任务中运行,但不幸的是,这个后端实例关机,所以我超过了我的免费配额限制。所以有人可以给我一个提示如何关闭后端实例后,令牌verfication?

解决方案

这是一个已知的问题Firebase Admin Java SDK,实际上是我们修复的一个难题。目前唯一的解决方法是使用支持在前端实例中使用此方法的更新版本的SDK(> = 4.0.4 )处理)。

不幸的是,在一个单独的问题中, verifyIdToken()方法在 4.1.0 由于依赖性不好而被释放。因此,您必须使用 4.0.4 或> = 4.1.1



对不起所有的麻烦!我们将获得固定的 verifyIdToken()方法。与此同时,版本 4.0.4 应该适合您。

更新



<第二个小问题是 verifyIdToken()方法在 Admin Java SDK 4.1.1版本


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.

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();

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?

解决方案

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).

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.

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

Update

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天全站免登陆