gpt4 book ai didi

flutter - "At least one of ID token and access token is required"带有 google 登录流程和 firebase 模拟器套件

转载 作者:行者123 更新时间:2023-12-05 05:36:53 25 4
gpt4 key购买 nike

我正在尝试使用 firebase 模拟器套件测试 google 登录流程。问题是谷歌登录不是一直收到 idToken 但 firebase 模拟器套件只支持 id_token,所以我无法通过这种方法登录。

编辑:

 Future<UserCredential> signInWithGoogle() async {
// Trigger the authentication flow
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();

// Obtain the auth details from the request
final GoogleSignInAuthentication? googleAuth =
await googleUser?.authentication;

// Create a new credential
final credential = GoogleAuthProvider.credential(
// Didn't fill accessToken arg cause firebase emulator only supports idToken.
// accessToken: googleAuth?.accessToken,
idToken: googleAuth?.idToken,
);

// Once signed in, return the UserCredential
return await firebaseAuth.signInWithCredential(credential);
}

我收到此错误 'accessToken != null || idToken != null':调用 GoogleAuthProvider.credential 时,至少需要 ID token 和访问 token 之一,使用 accessToken 我可以登录真实firebase 项目成功,并且都使用 API 31 模拟器在 Debug模式下进行了测试,因此 SHA-1 应该设置成功。

Google 登录版本 google_sign_in: ^5.4.0

最佳答案

Flutterfire cli 文档说:

if your Flutter app supports Android then the Android Google Services Gradle plugin will automatically be applied for you.

但它似乎对我不起作用,我已经尝试过 0.2.0 和 0.2.4 都没有为我添加 google-services 插件。所以只需手动添加即可。

关于flutter - "At least one of ID token and access token is required"带有 google 登录流程和 firebase 模拟器套件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73234092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com