Courtesy: GitHub

Google Sign-In Quickstart

The Google Sign-In Android quickstart demonstrates how to authenticate a user with GoogleSignInClient.

Introduction

Getting Started

  • Follow the quickstart guide to set up your project in Android Studio.
  • Run the sample on your Android device or emulator.
  • The running sample allows Google accounts on the device to sign-in.

Screenshots

Screenshot

Support

If you've found an error in this sample, please file an issue: https://github.com/googlesamples/google-services/issues

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub.

License

Copyright 2015 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

compileSdkVersion 25

applicationId "com.google.samples.quickstart.signin"

minSdkVersion 18

targetSdkVersion 25

versionCode 1

versionName "1.0"

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.android.support:appcompat-v7:25.2.0'

compile 'com.android.support:design:25.2.0'

compile 'com.google.android.gms:play-services-plus:9.6.1'

compileSdkVersion 26

applicationId "com.google.samples.quickstart.signin"

minSdkVersion 18

targetSdkVersion 26

versionCode 1

versionName "1.0"

compile 'com.android.support:appcompat-v7:26.1.0'

compile 'com.android.support:design:26.1.0'

compile 'com.google.android.gms:play-services-auth:11.6.0'

compile 'com.google.api-client:google-api-client:1.22.0'

compile 'com.google.api-client:google-api-client-android:1.22.0'

compile 'com.google.apis:google-api-services-people:v1-rev139-1.22.0'

package com.google.samples.quickstart.signin

uses-permission

  • android.permission.GET_ACCOUNTS

package com.google.samples.quickstart.signin

ChooserActivity

SignInActivity

SignInActivityWithDrive

IdTokenActivity

ServerAuthCodeActivity

RestApiActivity

ChooserActivity

Simple list-based Activity to redirect to one of the other Activities. The code here is uninteresting, {@link SignInActivity} is a good place to start if you are curious about {@code GoogleSignInApi}.

SignInActivity

Activity to demonstrate basic retrieval of the Google user's ID, email address, and basic profile.

SignInActivityWithDrive

Activity to demonstrate basic retrieval of the Google user's ID, email address, and basic profile, which also adds a request dialog to access the user's Google Drive.

IdTokenActivity

Demonstrates retrieving an ID token for the current Google user.

Validates that there is a reasonable server client ID in strings.xml, this is only needed to make sure users of this sample follow the README.

ServerAuthCodeActivity

Demonstrates retrieving an offline access one-time code for the current Google user, which can be exchanged by your server for an access token and refresh token.

Validates that there is a reasonable server client ID in strings.xml, this is only needed to make sure users of this sample follow the README.

RestApiActivity

Activity to demonstrate using the Google Sign In API with a Google API that uses the Google Java Client Library rather than a Google Play services API. See {@link #getContacts()} for how to access the People API using this method. * In order to use this Activity you must enable the People API on your project. Visit the following link and replace 'YOUR_PROJECT_ID' to enable the API: https://console.developers.google.com/apis/api/people.googleapis.com/overview?project=YOUR_PROJECT_ID