【问题标题】:GoogleCredentials does not work and paralyzes the applicationGoogleCredentials 不起作用并使应用程序瘫痪
【发布时间】:2019-06-02 03:03:43
【问题描述】:

我按照文档https://firebase.google.com/docs/admin/setup?authuser=0的步骤操作

但是代码的“GoogleCredentials.fromStream(serviceAccount)”部分;它停止应用程序并且不返回任何内容,甚至不返回错误消息。

我已包含以下库

  • firebase-admin-6.8.1.jar

  • google-auth-library-credentials-0.15.0.jar

  • google-auth-library-oauth2-http-0.15.0.jar

  • appengine-api-1.0-sdk-1.9.74.jar

请给我一些帮助,谢谢

        String token=null;
        FirebaseOptions options=null;
        FileInputStream serviceAccount=null;                    
        try {
            serviceAccount = new FileInputStream(Aplicacion.ruta_firebase_js);            
        }catch(FileNotFoundException ex) {
            log("Ruta de clave de firebase no encontrada: "+ex.getMessage());
        }           

        if(serviceAccount!=null){ 
            try {

                GoogleCredentials gc=GoogleCredentials.fromStream(serviceAccount);                
                log(gc.toString());
                options = new FirebaseOptions.Builder()
                        .setCredentials(gc)
                        .setDatabaseUrl("https://xxxxx-xxxxxx.firebaseio.com")
                        .build();
            } catch(FileNotFoundException ex) {
                log("Ruta de clave de firebase no encontrada: "+ex.getMessage());
            }catch (IOException ex){ 
                log("Error autenticando en Firebase: "+ex.getMessage());
            } 
        }


        if(options!=null){ 
            FirebaseApp.initializeApp(options);                    
            try {
                String uid = "Rocco-ergvrw98";
                token = FirebaseAuth.getInstance().createCustomToken(uid);
                HashMap p=new HashMap();
                p.put("accion", "tokenfirebase");
                p.put("token", token);
                Rocco.servidor_enlinealizate.enviar(indice, p); 

            } catch (FirebaseAuthException ex) {
                log("Error obtenmiendo token: "+ex.getMessage());
            };
        }
        return token;
    }

【问题讨论】:

    标签: firebase


    【解决方案1】:

    解决了!我必须将这些书店包括在我的项目中

    • api-common-1.8.1
    • commons-logging-1.2
    • firebase-admin-6.8.1
    • google-api-client-1.29.0
    • google-http-client-1.29.1
    • google-http-client-gson-1.29.1
    • google-http-client-jackson2-1.29.1
    • google-oauth-client-1.29.0
    • gson-2.8.5
    • guava-27.1-jre
    • httpclient-4.5.8
    • httpcore-4.4.11
    • jackson-core-2.9.9
    • jackson-core-asl-1.9.13
    • jsr305-3.0.2
    • protobuf-java-3.8.0
    • slf4j-api-1.7.26
    • slf4j-simple-1.7.26
    • xpp3-1.1.6

    https://mvnrepository.com/中提供了谁的更新版本

    【讨论】:

      猜你喜欢
      • 2021-10-16
      • 2021-11-18
      • 2011-02-12
      • 1970-01-01
      • 1970-01-01
      • 2015-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多