{"id":22048606,"url":"https://github.com/stevdza-san/onetapcompose","last_synced_at":"2025-07-23T20:31:56.647Z","repository":{"id":113246129,"uuid":"570949993","full_name":"stevdza-san/OneTapCompose","owner":"stevdza-san","description":"This library allow you to easily integrate One-Tap Sign in with Google(Credential Manager) in your project with Jetpack Compose. It keeps away all the boilerplate code.","archived":false,"fork":false,"pushed_at":"2024-08-06T06:27:58.000Z","size":1177,"stargazers_count":192,"open_issues_count":5,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-08-06T08:16:25.755Z","etag":null,"topics":["android","jetpack-compose","kotlin","one-tap-sign-in","sign-in-with-google"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stevdza-san.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-26T16:56:04.000Z","updated_at":"2024-08-06T06:28:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"42a7af05-3faa-48af-907f-fe7c6516ec35","html_url":"https://github.com/stevdza-san/OneTapCompose","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevdza-san%2FOneTapCompose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevdza-san%2FOneTapCompose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevdza-san%2FOneTapCompose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevdza-san%2FOneTapCompose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevdza-san","download_url":"https://codeload.github.com/stevdza-san/OneTapCompose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227351655,"owners_count":17768412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","jetpack-compose","kotlin","one-tap-sign-in","sign-in-with-google"],"created_at":"2024-11-30T14:12:54.832Z","updated_at":"2024-11-30T14:12:54.975Z","avatar_url":"https://github.com/stevdza-san.png","language":"Kotlin","funding_links":["https://ko-fi.com/stevdza_san"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eOne-Tap Sign in with Google\u003c/h1\u003e\u003c/br\u003e\n\n\u003ch1 align=\"center\"\u003eDeveloper Notice ⚠️\u003c/h1\u003e \n\u003cp align=\"center\"\u003e\nI'm not planning to maintain this library anymore, because there's already a better solution which is KMP ready, and available for both Android and iOS. Please do migrate to a new KMP Auth library \u003ca href=\"https://github.com/mirzemehdi/KMPAuth\"\u003eHERE\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://jitpack.io/#stevdza-san/OneTapCompose/1.0.14\"\u003e\u003cimg alt=\"License\" src=\"https://badgen.net/badge/Jitpack/1.0.14/orange?icon=github\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/stevdza-san\"\u003e\u003cimg alt=\"Profile\" src=\"https://badgen.net/badge/Github/stevdza_san/green?icon=github\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\nThis library allow you to easily integrate One-Tap Sign in with Google(\u003ca href=\"https://developer.android.com/training/sign-in/credential-manager\"\u003eCredential Manager\u003c/a\u003e) to your project with Jetpack Compose. \nIt hides all the boilerplate code away from you. You get an extracted \u003ca href=\"#google-user\"\u003eGoogle User\u003c/a\u003e object that you can use to obtain a basic user information. And there's a new \u003ca href=\"#sign-in-with-google-button\"\u003eOneTapGoogleButton\u003c/a\u003e composable that you can use out of the box, with various customization options.\n\u003c/p\u003e\u003cbr\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/stevdza-san/OneTapCompose/blob/master/previews/OneTap.gif\" width=\"268\"/\u003e\n  \u003cimg src=\"https://github.com/stevdza-san/OneTapCompose/blob/master/previews/OneTap2.gif\" width=\"268\"/\u003e\n\u003c/p\u003e\n\n# Download\n\u003ca href=\"https://jitpack.io/#stevdza-san/OneTapCompose/1.0.14\"\u003e\u003cimg alt=\"License\" src=\"https://badgen.net/badge/Jitpack/1.0.14/orange?icon=github\"/\u003e\u003c/a\u003e\n\n### Gradle\n\nAdd the dependency below to your module's `build.gradle` file:\n```gradle\ndependencies {\n    implementation(\"com.github.stevdza-san:OneTapCompose:1.0.14\")\n}\n```\nAdd a repository in your `settings.gradle` file:\n```\ndependencyResolutionManagement {\n    repositories {\n        ...\n        maven(url = \"https://jitpack.io\")\n    }\n}\n```\n# Usage\n\nBefore you can use this library, you need to create a new project on a \u003ca href=\"https://cloud.google.com/\"\u003eGoogle Cloud Platform\u003c/a\u003e.\nYou need to create OAuth Client ID \u003ci\u003e(ANDROID \u0026 WEB)\u003c/i\u003e, because you will need that same Client ID (WEB), in order to implement One-Tap Sign in with Google.\n\u003c/br\u003e\u003c/br\u003e\nAfter that, just call `OneTapSignInWithGoogle()` function, and pass that same information you've obtained through Google Cloud Platform.\nYou will also pass `OneTapSignInState`, because that state is used later to trigger One-Tap dialog.\n\n```kotlin\n    val state = rememberOneTapSignInState()\n    OneTapSignInWithGoogle(\n        state = state,\n        clientId = \"YOUR_CLIENT_ID\",\n        onTokenIdReceived = { tokenId -\u003e\n            Log.d(\"LOG\", tokenId)\n        },\n        onDialogDismissed = { message -\u003e\n            Log.d(\"LOG\", message)\n        }\n    )\n```\n\nTo trigger One-Tap dialog, just call `open()` function.\n\n```kotlin\nButton(onClick = { state.open() }) {\n    Text(text = \"Sign in\")\n}\n```\n\n# Google User\n\nAnd if you wish to extract a user information from a token id, that's now possible too! `getUserFromTokenId()` allows you to do exactly that. It returns a `GoogleUser` object, that contains lot's of different information related to that same user.\n\n```kotlin\nonTokenIdReceived = { tokenId -\u003e\n    Log.d(\"LOG\", getUserFromTokenId(tokenId).toString())\n}\n```\n\nAvailable `GoogleUser` information:\n- Sub\n- Email\n- EmailVerified\n- FullName\n- GivenName\n- FamilyName\n- Picture\n- IssuedAt\n- ExpirationTime\n- Locale\n\n# Sign in with Google Button\n\nYou can also use a drop-in opinionated button composable that works out of the box and encapsulates all the\nsign in logic and follows Google's [Sign in with Google Branding Guidelines](https://developers.google.com/identity/branding-guidelines):\n\n```kotlin\nOneTapGoogleButton(\n    clientId = \"YOUR_CLIENT_ID\"\n)\n```\n\nAccording to the design guidelines, the button is available in 3 themes:\n1. Dark\n2. Light\n3. Neutral\n\n\u003cimg src=\"https://github.com/stevdza-san/OneTapCompose/blob/master/previews/ButtonDark.png\" width=\"300\"/\u003e\n\u003cimg src=\"https://github.com/stevdza-san/OneTapCompose/blob/master/previews/ButtonLight.png\" width=\"300\"/\u003e\n\u003cimg src=\"https://github.com/stevdza-san/OneTapCompose/blob/master/previews/ButtonNeutral.png\" width=\"300\"/\u003e\n\nYou can customise the theme using the `theme` parameter in the composable:\n```kotlin\nOneTapGoogleButton(\n    clientId = \"YOUR_CLIENT_ID\",\n    theme = GoogleButtonTheme.Neutral\n)\n```\n\nThe buttons are also available in icon-only mode for all the themes:\n\n\u003cimg src=\"https://github.com/stevdza-san/OneTapCompose/blob/master/previews/IconButtonDark.png\" width=\"100\"/\u003e\n\u003cimg src=\"https://github.com/stevdza-san/OneTapCompose/blob/master/previews/IconButtonLight.png\" width=\"100\"/\u003e\n\u003cimg src=\"https://github.com/stevdza-san/OneTapCompose/blob/master/previews/IconButtonNeutral.png\" width=\"100\"/\u003e\n\nIt can be activated using the `iconOnly` parameter in the composable:\n\n```kotlin\nOneTapGoogleButton(\n    clientId = \"YOUR_CLIENT_ID\",\n    iconOnly = true\n)\n```\n\n## Button API\n| Name  | Type | Description |\n| ------------- | ------------- | ------------- |\n| clientId  | String  | CLIENT ID (Web) of your project, that you can obtain from a Google Cloud Platform.  |\n| state  | OneTapSignInState  | One-Tap Sign in State. Can be used to detect whether the sign in operation has already been triggered.  |\n| rememberAccount  | Boolean  | Remember a selected account to sign in with, for an easier and quicker sign in process.  |\n| nonce  | String?  | Optional nonce that can be used when generating a Google Token ID  |\n| onTokenIdReceived  | ((String) -\u003e Unit)?  | Lambda that will be triggered after a successful authentication. Returns a Token ID.  |\n| onUserReceived  | ((String) -\u003e Unit)?  | This function returns a GoogleUser object using the received tokenId.  |\n| onDialogDismissed  | ((String) -\u003e Unit)?  | Lambda that will be triggered when One-Tap dialog disappears. Returns a message in a form of a string.  |\n| iconOnly  | Boolean  | Whether the button should only show the Google logo.  |\n| theme  | GoogleButtonTheme  | Sets the button style to either be Light, Dark, or Neutral which is in accordance with the official Google design guidelines.  |\n| colors  | ButtonColors  | ButtonColors that will be used to resolve the colors for this button in different states.  |\n| border  | BorderStroke?  | the border to draw around the container of this button  |\n| shape  | Shape  | defines the shape of this button's container, border (when border is not null)  |\n| onClick  | (() -\u003e Unit)?  | called when this button is clicked  |\n\n# Release Build\nIf you are planning on publishing your app, be sure to generate a release SHA-1 fingerprint, and create a new oAuth credentials on your Google Cloud Platform project.\nAlso when you upload your app on Play Console, you'll find there a section (`Release \u003e Setup \u003e App signing`) that will generate the release SHA-1 fingerprint. You take it and create another oAuth credential.\n\n# Troubleshoot\nIn some cases you may encounter \u003ci\u003e\"Google Account not Found.\"\u003c/i\u003e message inside `onDialogDismiss` lambda, even if you have already connected a Google account\non your Android Emulator. Android emulators are prone to that issues \u003ci\u003e(Not sure why and when that's gonna get fixed)\u003c/i\u003e.\nMy suggestion in that case is to try and add a Google account on some other Android Emulator.\nIf that doesn't work either, then use a real device instead.\n\n\u003e It's important to implement your own rate limiting of One Tap sign-in prompts. If you don't, and a user cancels several prompts in a row, the One Tap client will not prompt the user for the next 24 hours.\n\nAlso to debug your app better, check the logs and search for a `OneTapCompose` tag, it might contain additional information to help you out with your issue.\n\n# Like what you see? :yellow_heart:\n⭐ Give a star to this repository. \u003cbr /\u003e\n☕ Buy me a coffee: https://ko-fi.com/stevdza_san\n\n# License\n```xml\nDesigned and developed by 2022 stevdza-san (Stefan Jovanović)\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevdza-san%2Fonetapcompose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevdza-san%2Fonetapcompose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevdza-san%2Fonetapcompose/lists"}