Google登录-无法在生产环境中使用 [英] Google signin - not working in production
本文介绍了Google登录-无法在生产环境中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在仿真器和真实设备上进行测试时,Google登录有效,但是,在生产环境中,它不起作用.我已将SHA 1密钥添加到我的Firestore项目中.
Google sign in works when testing on the emulator and a real device, however, in production it doesn't work. I have added the SHA 1 key to my Firestore project.
我该如何解决?
Future<User> googleSignIn() async {
try {
GoogleSignInAccount googleSignInAccount = await Global.googleSignIn.signIn();
GoogleSignInAuthentication googleAuth =
await googleSignInAccount.authentication;
final AuthCredential credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
UserCredential result = await Global.fbAuth.signInWithCredential(credential);
User user = result.user;
updateUserData(user);
return user;
} catch (error) {
print(error);
return null;
}
}
onPressed: () async {
showDialogue(context);
var user = await loginMethod();
if (user != null) {
hideProgressDialogue(context);
Navigator.pushReplacementNamed(context, SharedStrings.userInfoPath);
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now,
// so `flutter run --release` works.
signingConfig signingConfigs.release
}
推荐答案
上传到Play商店后,Play商店会生成自己的SH1,我们必须在Google控制台的第二个键中替换它.
After Uploading to play store, Play store generate its own SH1 which we have to replace in second key in google console.
转到Google控制台>应用程序签名>副本SH1由控制台生成.在Google登录控制台中添加该内容,然后从第二个键替换它.
Go to google console>app signing> copy SH1 generate by console. Add that in google sign in console replace it from 2nd key.
这篇关于Google登录-无法在生产环境中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文