[英]Issue In Firebase Custom Authentication And Service Account
Ok, so first of all I am not very much an expert in both java or android, in fact I am just beginner. 好的,首先我不是Java或android方面的专家,实际上我只是个初学者。 So if anything sounds silly or irritating pardon me, I am on the verge of being blocked from asking any questions.
因此,如果有什么听起来很愚蠢或令人讨厌的事情,我将被禁止提出任何问题。
So, my issue is that while authenticating my server with firebase, I am facing some trouble while setting service account and creating custom token. 因此,我的问题是,在使用Firebase对服务器进行身份验证时,在设置服务帐户和创建自定义令牌时遇到了一些麻烦。
https://firebase.google.com/docs/admin/setup
https://firebase.google.com/docs/admin/setup
https://firebase.google.com/docs/auth/admin/create-custom-tokens
https://firebase.google.com/docs/auth/admin/create-custom-tokens
I am taking help from here and following these steps, and this is what i have done. 我正在从这里寻求帮助,并按照以下步骤进行操作,这就是我所做的。
FileInputStream serviceAccount = new FileInputStream("path/to/serviceAccountKey.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
.setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
.build();
FirebaseApp.initializeApp(options);
FirebaseAuth.getInstance()
.createCustomToken(uid)
.addOnSuccessListener(new OnSuccessListener<String>() {
@Override
public void onSuccess(String customToken)
{
// Send token back to client
}
});
But I am getting very unusual errors, ie 但是我遇到了非常不寻常的错误,即
1) On service account - The method setCredential(FirebaseCredential)
is undefined for the type FirebaseOptions.Builder
1)在服务帐户上-未为类型
FirebaseOptions.Builder
定义方法setCredential(FirebaseCredential)
Now I've read that setserviceaccount is deprecated, but when i am using it, its not giving me any error 现在,我已经阅读了setserviceaccount已弃用,但是当我使用它时,它并没有给我任何错误
2) On Creating Custom Token - The method addOnSuccessListener(new OnSuccessListener<String>(){})
is undefined for the type String 2)创建自定义令牌时-未为类型String定义方法
addOnSuccessListener(new OnSuccessListener<String>(){})
It is another method error, and also I don't know how to send the token back to client. 这是另一个方法错误,而且我也不知道如何将令牌发送回客户端。 I couldn't find any example that how should i approach it.
我找不到任何应该如何处理的示例。 Any help will be greatly appreciated.
任何帮助将不胜感激。
Any example that how others send there token to client, would be great. 任何其他人如何将令牌发送到客户端的示例都很好。
Ok, so finally i have solved the issue,the issue was that in my pom.xml I was also using (Firebase Server SDK Library » 3.0.3)maven repository. 好的,所以终于解决了这个问题,问题是在pom.xml中,我还在使用(Firebase Server SDK库»3.0.3)maven存储库。 And thats why there were method issues.
那就是为什么存在方法问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.