I am following this to integrate google authentication in my app. It is working fine in debug apks, but when released, it is failing every time.
I have registered both debug and relese SHA-1 key on cloud platform.
code snippet for reference-
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();
}
The SignIn prompt opens, does ask for google account, but does not ask for permissions of the requested scopes and retuns null for GoogleSignInAccount.
