本文整理汇总了Java中com.google.firebase.auth.FirebaseToken.getUid方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseToken.getUid方法的具体用法?Java FirebaseToken.getUid怎么用?Java FirebaseToken.getUid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.firebase.auth.FirebaseToken
的用法示例。
在下文中一共展示了FirebaseToken.getUid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveUser
import com.google.firebase.auth.FirebaseToken; //导入方法依赖的package包/类
@Override
protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
final FirebaseAuthenticationToken authenticationToken = (FirebaseAuthenticationToken) authentication;
final CompletableFuture<FirebaseToken> future = new CompletableFuture<>();
firebaseAuth.verifyIdToken(authenticationToken.getToken()).addOnSuccessListener(future::complete);
try {
final FirebaseToken token = future.get();
return new FirebaseUserDetails(token.getEmail(), token.getUid());
} catch (InterruptedException | ExecutionException e) {
throw new SessionAuthenticationException(e.getMessage());
}
}
示例2: validateToken
import com.google.firebase.auth.FirebaseToken; //导入方法依赖的package包/类
private Boolean validateToken(String token) {
Task task = FirebaseAuth.getInstance().verifyIdToken(token);
// TODO refactor
// wait for task to finish
while (!task.isComplete()) {
}
FirebaseToken decodedToken = (FirebaseToken) task.getResult();
return decodedToken.getUid() != null && !decodedToken.getUid().isEmpty();
}
示例3: verifyIdToken
import com.google.firebase.auth.FirebaseToken; //导入方法依赖的package包/类
public static void verifyIdToken(String idToken) throws InterruptedException, ExecutionException {
// [START verify_id_token]
// idToken comes from the client app (shown above)
FirebaseToken decodedToken = FirebaseAuth.getInstance().verifyIdTokenAsync(idToken).get();
String uid = decodedToken.getUid();
// [END verify_id_token]
System.out.println("Decoded ID token from user: " + uid);
}