Android Google SignIn not working in debug mode: GoogleSignInResult is false

后端 未结 6 951
我在风中等你
我在风中等你 2020-12-17 08:36

I have been following this tutorial to get Google SignOn going: https://developers.google.com/identity/sign-in/android/start-integrating

When I run my application lo

6条回答
  •  一个人的身影
    2020-12-17 09:30

    In addition to the above answers, I came across one case where the problem was caused due to the configuration was mismatched to the google-services.json file:

    It is also possible that the clientId was specifically assigned in the GoogleSignInOptions Builder as shown below:

        String serverClientId = "xxxxx-yyyy.apps.googleusercontent.com";
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .requestIdToken(serverClientId)
                .build();
    

    If this is the case, it is possible to remove the reference to the serverClientId and the requestIdToken call as shown below:

        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();
    

    This would then rely on the google-services.json as opposed to the hard-coded value during configuration.

    I hope it saves someone else the trouble that I had trying to diagnose the fault with my project.

提交回复
热议问题