简体   繁体   English

在Google App Engine上验证Firebase令牌

[英]Verify Firebase Token at Google App Engine

I am developing an Application at Google App Engine. 我正在Google App Engine上开发应用程序。 I am using Cloud Endpoints for the communication between an Android App at my Backend at Google App Engine. 我正在使用Cloud Endpoints在Google App Engine后端的Android App之间进行通信。 The Android client uses Firebase Authentication and sends with every call the Firebase token the Cloud Endpoints. Android客户端使用Firebase身份验证,并在每次调用Firebase令牌时发送Cloud Endpoints。

At Google App Engine I use the following code to verify the Firebase Token. 在Google App Engine中,我使用以下代码来验证Firebase令牌。 I am using the Firebase Admin SDK 4.0.3 我正在使用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. 该任务的执行是在Google App Engine后端任务上运行的,但是很遗憾,此后端实例没有关闭,因此我超出了我的免费配额限制。 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. 这是Firebase Admin Java SDK的已知问题,实际上是我们很难修复的错误。 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). 目前唯一的解决方法是使用更新版本的SDK(> = 4.0.4 ),该版本支持在前端实例(在处理后彻底关闭)中使用此方法。

Unfortunately, in a separate issue, the verifyIdToken() method is broken in the 4.1.0 release due to a bad dependency. 不幸的是,在另一个问题中,由于错误的依赖关系, verifyIdToken()方法在4.1.0版本中被破坏。 So, you'll have to use either 4.0.4 or >= 4.1.1 . 因此,您必须使用4.0.4或> = 4.1.1

Sorry for all the troubles! 对不起,所有的麻烦! We will get the verifyIdToken() method fixed ASAP. 我们将尽快verifyIdToken()方法。 In the meantime, version 4.0.4 should work for you. 同时,版本4.0.4应该适合您。

Update 更新

The second, smaller issue with the verifyIdToken() method was fixed in version 4.1.1 of the Admin Java SDK . verifyIdToken()方法的第二个较小的问题已在Admin Java SDK的4.1.1版本中修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM