我正在跟踪这,以便在我的应用程序中集成谷歌认证。它在调试apks方面运行良好,但是当发布时,每次都会失败。
我已经在云平台上注册了调试和relese SHA-1密钥。
供参考的代码片段-
private void someMethid(){
String languageURL = "https://www.googleapis.com/auth/profile.language.read";
String genderURL = "https://www.googleapis.com/auth/user.gender.read";
String birthdayURL = "https://www.googleapis.com/auth/user.birthday.read";
GoogleSignInOptions option = new
GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestScopes(
new Scope(languageURL),
new Scope(genderURL),
new Scope(birthdayURL)
)
.build();
client = GoogleSignIn.getClient(this, option);
signIn();
}
private void signIn() {
Intent signInIntent = client.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
handleSignInResult(task);
}
}
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
GoogleSignInAccount acct = null;
try {
acct = completedTask.getResult(ApiException.class);
if (acct != null) {
fetchData(acct);
}
else {
showDialogMessage("Email verification failed", "failed to get Google account information", false);
client.revokeAccess();
client.signOut();
}
} catch (ApiException e) {
e.printStackTrace();
showDialogMessage("Email verification failed", "failed to get Google account information", false);
client.revokeAccess();
client.signOut();
}SignIn提示符将打开,确实会请求GoogleSignInAccount,但不会请求所请求的作用域的权限,对于GoogleSignInAccount也不请求null。
发布于 2021-03-23 15:49:04
当你说When released的时候,你是说当你从Google安装这个应用程序的时候吗?如果使用"Play App Signing“,则需要从Google控制台添加签名密钥,而不是从存储库/密钥存储库添加签名密钥。这是因为Google Play代表你在应用程序上签名。
诊断您的问题:--看起来应用程序是用与身份验证服务期望的密钥不同的密钥签名的,所以服务拒绝它。你知道这件事后就辞职了。
https://support.google.com/googleplay/android-developer/answer/9842756?hl=en
如果这样做不起作用,请提供更多细节:)。如果你需要更多的帮助,请告诉我。
发布于 2021-03-23 15:54:50
上传到play商店后,Play商店生成自己的SH1,我们必须在google的第二个键中替换它。
转到google console>app signing>复制由控制台生成的SH1。在google的控制台上签名,从第二个键替换它。

https://stackoverflow.com/questions/66766528
复制相似问题