Skip to content

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

Google Sign-Up Example – Android

A simple Android application demonstrating Google Sign-Up using AndroidX Credential Manager and Google Identity Services, built with Kotlin and Jetpack Compose.

The project demonstrates how to integrate a Google Sign-Up button and retrieve Google account information and an ID token using the modern Android credential APIs.

Overview

This project is a practical implementation example intended for learning and demonstrating Google authentication integration on Android.

It uses example configuration values rather than real user credentials or production Google account identities.

Important: This is a demonstration project, not a complete production authentication system. It retrieves a Google ID token but does not implement backend authentication, token verification, or account creation.

Features

  • Google Sign-Up button integration.
  • Google account selection using Credential Manager.
  • Google ID token retrieval.
  • Access to basic Google account information, including email and display name.
  • Asynchronous credential handling using Kotlin Coroutines.
  • Modern Android UI built with Jetpack Compose and Material 3.
  • Support for Android 8.0 (API 26) and above.

Tech Stack

Technology Purpose
Kotlin Primary programming language
Jetpack Compose Declarative UI
Material 3 UI components and styling
AndroidX Credential Manager Credential management
Google Identity Services Google ID token credentials
Kotlin Coroutines Asynchronous operations
Gradle Kotlin DSL Build configuration

Requirements

  • Android Studio with support for the project's Android Gradle Plugin.
  • JDK 17 or compatible version required by the configured Android Gradle Plugin.
  • Android SDK 37.
  • Android device or emulator running Android 8.0 (API 26) or later.
  • Google account and Google Play Services for testing.

Getting Started

1. Clone the repository

git clone https://github.com/MagdyDeveloper007/GoogleSignUpExample.git

Open the project in Android Studio and allow Gradle to synchronize the dependencies.

2. Configure Google OAuth

To test the Google Sign-Up flow with your own Google account:

  1. Open Google Cloud Console.
  2. Create or select a Google Cloud project.
  3. Configure the OAuth consent screen.
  4. Create an Android OAuth client using your application's package name and signing certificate SHA-1 fingerprint.
  5. Create a Web application OAuth client.
  6. Copy the Web Client ID.

3. Configure the Web Client ID

Open MainActivity.kt and locate:

val webClientId = "YOUR_WEB_CLIENT_ID.apps.googleusercontent.com"

Replace the placeholder with your own Web Client ID.

Note: The example repository does not contain real OAuth credentials. Use your own Google Cloud configuration when testing.

4. Run the application

Build and run the application using Android Studio, or execute:

./gradlew assembleDebug

On Windows:

gradlew.bat assembleDebug

Authentication Flow

The application follows this simplified flow:

  1. The user taps the Google Sign-Up button.
  2. Credential Manager initiates the Google account selection flow.
  3. The user selects a Google account.
  4. Google Identity Services provides a Google ID token credential.
  5. The application retrieves the available account information, including email and display name.

The retrieved ID token can subsequently be sent to a trusted backend for server-side verification.

Security Considerations

This project is intended for demonstration purposes.

For a production implementation:

  • Never hardcode real credentials or sensitive configuration values.
  • Never log Google ID tokens, access tokens, or other authentication secrets.
  • Send the Google ID token to a trusted backend over HTTPS.
  • Verify the ID token on the server side, including its signature, issuer, audience, and expiration.
  • Do not treat client-side account information as proof of authentication.
  • Implement proper session management and secure logout handling.
  • Follow Google's OAuth and authentication security recommendations.

Project Scope and Limitations

The current implementation focuses on the Android-side Google credential retrieval flow.

It does not include:

  • Backend integration.
  • Server-side ID token verification.
  • User registration or account persistence.
  • Application session management.
  • Production authentication infrastructure.

References

License

No open-source license has been specified for this repository.