Try Sign-In for Android

Use our Android sample app to see how Sign-In works, or add Sign-In to your existing app.

Required: The latest versions of Android Studio and Google Play Services.

Get the project

If this is your first time using a Google services sample, check out the google-services repository.

$ git clone

Open Android Studio.

Select File > Open, browse to where you cloned the google-services repository, and open google-services/android/signin.

Get a configuration file

To use the sample, you need to provide some additional information to get a configuration file and finish setting up your project. Use the package name for the sample.

After you complete the registration, download the google-services.json file to add to your project.

Get a Configuration File

Add the configuration file to your project

Copy the google-services.json file you just downloaded into the app/ or mobile/ directory of your Android Studio project. Open the Android Studio Terminal pane:

$ mv path-to-download/Downloads/google-services.json app/
$ move path-to-download/Downloads/google-services.json app/

Create a web client ID for your server

The sample's IdTokenActivity and ServerAuthCodeActivity examples require you to specify an OAuth 2.0 web client ID. In a real app, this client ID would represent your app's backend server. To create a client ID:

  1. Open the Credentials page in the API Console.
  2. Click Add credentials > OAuth 2.0 client ID.
  3. Select Web application.
  4. Click Create.

Your new client ID is displayed. Copy and paste the client ID into your project's strings.xml file:

<string name="server_client_id">YOUR_SERVER_CLIENT_ID</string>

Run the sample

Now you're ready to build the sample and run it from Android Studio.

Build the sample and click the run button and select a connected device or emulator with Google Play Services 11.6.0 or newer.

How it works

The application builds a GoogleSignInClient, specifying the sign-in options it needs. Then, when the sign-in button is clicked, the application starts the sign-in intent, which prompts the user to sign in with a Google account.

// Configure sign-in to request the user's ID, email address, and basic
// profile. ID and basic profile are included in DEFAULT_SIGN_IN.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
// Build a GoogleSignInClient with the options specified by gso.
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
private void signIn() {
    Intent signInIntent = mGoogleSignInClient.getSignInIntent();
    startActivityForResult(signInIntent, RC_SIGN_IN);

Next steps

If you want to see how you can implement Google Sign-In in your own app, take a look at our implementation guide.

Add Sign-In to your app

Did you have a good experience? Run into trouble? Let us know!