我正在尝试使用云功能使用自定义令牌对用户进行身份验证。生成令牌的代码是:
export const test = functions.https.onCall(() => {
const uid = 'test_uid'
admin.auth().createCustomToken(uid)
.then((customtoken) => {
console.log(customtoken)
return customtoken
}).catch((error) => {
console.log(error)
})
})
客户端的代码是:
private void getmessage() {
FirebaseFunctions.getInstance()
.getHttpsCallable("test")
.call()
.addOnCompleteListener(this, new OnCompleteListener<HttpsCallableResult>() {
@Override
public void onComplete(@NonNull Task<HttpsCallableResult> task) {
if(task.isSuccessful()){
Toast.makeText(getApplicationContext(), task.getResult().getData().toString(), Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), "Task is NOT Successful", Toast.LENGTH_LONG).show();
}
}
});
}
令牌成功登录到控制台,但在客户端返回空值。有什么我做错了吗?