Search code examples
androidgoogle-clientgoogle-signingooglesigninaccount

How to get serverID for Google Authentication


So I have 2 projects, and I need to merge them. And in the one that I need to delete I have the following key, which works with GoogleSignInOptions: enter image description here Now, in my new project. I don't know how to create this. It says that it is a Service account client, but the: Create Credentials -> Create Oauth Client ID -> only gives me this options:

Web application Android Chrome App iOS PlayStation 4 Other

I tried, now there is a button: Create Credentials -> Service Account Key -> but this returns a different object, and still doesn't work. I tried it, but only with the App Engine Default Service Account.

But I am pretty certain I did not do it this way, when implementing the first time. Then I did something that made me download a google-services.json, and then it also gave me the Server Client ID. I haven't worked with this in a while, so I'm lost. Am I doing something wrong?

This is my code:

String serverID = getString(R.string.server_client_id);
    Log.i("","handleSignInResult serverid: " + serverID);
    gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestIdToken(serverID)
            .requestServerAuthCode(serverID)
            .build();

Solution

  • I think you have to pick "other":

    enter image description here

    enter image description here

    enter image description here

    enter image description here