1

我最近在我的应用程序中集成了 Firebase App Check 并强制执行它来调用 Cloud Functions。问题是在我的 OnePlus 8T 上一切正常,而在所有其他设备上调用云功能失败。我正在所有设备上从 Google Play 商店(上传到内部测试)安装应用程序。

云函数日志中显示以下错误消息:

errorInfo:
   { code: 'app-check/invalid-argument',
     message: 'Decoding App Check token failed. Make sure you passed the entire string JWT which represents the Firebase App Check token.' },
     codePrefix: 'app-check' 
   } 

正在使用的 Firebase 依赖项列表如下:

    implementation platform('com.google.firebase:firebase-bom:28.4.0')
    implementation 'com.google.firebase:firebase-appcheck-safetynet:16.0.0-beta02'
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-messaging'
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
    implementation 'com.google.firebase:firebase-functions-ktx'
    implementation 'com.google.firebase:firebase-config-ktx'

Firebase App Check 在 Application 类中初始化如下:

private fun initFirebaseAppCheck() {
        FirebaseApp.initializeApp(this)
        appCheck.installAppCheckProviderFactory(SafetyNetAppCheckProviderFactory.getInstance())
    }

正在调用的云函数的代码

import * as functions from "firebase-functions";
import vision from "@google-cloud/vision";

const client = new vision.ImageAnnotatorClient();

export const fetchData = functions.https.onCall(async (data, context) => {
 
  if (context.app == undefined) {
    throw new functions.https.HttpsError(
        'failed-precondition',
        'The function must be called from an App Check verified app.')
  }

  // Function Logic here
});

应用在 OnePlus 8T 上运行时的日志

Callable request verification passed {"verifications":{"auth":"MISSING","app":"VALID"}}

我不知道为什么 Firebase App Check 只在一台设备上通过而在所有其他设备上都失败了。任何帮助将不胜感激。

4

0 回答 0