我有一個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?
}
這不,雖然春天的方式。 –