我有一个Spring Boot REST应用程序,它取决于在Firebase中完成的身份验证。在客户端,Firebase生成一个令牌,在Spring Boot中,我需要验证uid。但是我注意到代码处于回调模式,那么如何实现Spring Boot函数以完成任务?如何使用Firebase与Spring引导REST应用程序?
@RequestMapping(value = "/api/restCall", method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public Object restCall(@RequestBody Parameters requestBody) throws Exception {
// idToken comes from the client app (shown above)
String idToken = requestBody.getToken();
Task<FirebaseToken> task = FirebaseAuth.getInstance().verifyIdToken(idToken)
.addOnSuccessListener(new OnSuccessListener<FirebaseToken>() {
@Override
public void onSuccess(FirebaseToken decodedToken) {
String uid = decodedToken.getUid();
// process the code here
}
});
// how do I return here, since the code is in the onSuccess?
// do I return as a DeferredResult?
}
这不,虽然春天的方式。 –