我需要在进行身份验证时从Firebase获取令牌,然后将令牌转移到后端。我有几种情况下auth。我还没有使用令牌。下一步应该怎么做?
final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
Future<FirebaseUser> getCurrentUser() => _firebaseAuth.currentUser();
Future<AuthResult> signInWithGoogle() async {
final authentication = await GoogleAuth().signIn();
final credential = GoogleAuthProvider.getCredential(
accessToken: authentication.accessToken,
idToken: authentication.idToken,
);
return _firebaseAuth.signInWithCredential(credential);
}
Future<AuthResult> signInWithEmail(String email, String password) {
return _firebaseAuth.signInWithEmailAndPassword(
email: email,
password: password,
);
}
答案 0 :(得分:0)
您是否正在寻找类似的东西?
final UserCredential authResult = await _firebaseAuth.signInWithCredential(credential);
final token = authResult.credential.token;