Google 登录在上传到 Play 商店之前工作正常,但在将应用上传到商店后,Google 登录不起作用,并且在 handleSignInResult() 方法中始终返回 false。
下面是使用的代码:
try {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
// .requestEmail()
.requestIdToken(getString(R.string.server_client_id))
.requestEmail()
// .requestScopes(new Scope(Scopes.DRIVE_APPFOLDER))
// .requestServerAuthCode(getString(R.string.server_client_id), false)
.build();
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.enableAutoManage(getActivity() /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
} catch (IllegalStateException e) {
Log.e("IllegalStateException ", e.toString());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_GET_TOKEN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
}
private void handleSignInResult(GoogleSignInResult result) {
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
GoogleSignInAccount acct = result.getSignInAccount();
}
最佳答案
您必须更新您的 Google Developer Console API。 内部凭据:
https://console.developers.google.com/apis/
如果您的应用程序在调试中工作。将用于发布 key 的 SHA 添加到您的 key 。
关于android - 在 Play 商店上传应用程序后,Google 登录无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38693135/