Giter Club home page Giter Club logo

onetapcompose's Introduction

One-Tap Sign in with Google


License Profile


This library allow you to easily integrate One-Tap Sign in with Google to your project with Jetpack Compose.
It hides all the boilerplate code away from you.


Download

License

Gradle

Add the dependency below to your module's build.gradle file:

dependencies {
    implementation 'com.github.stevdza-san:OneTapCompose:1.0.3'
}

Add a repository in your settings.gradle file:

dependencyResolutionManagement {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Usage

Before you can use this library, you need to create a new project on a Google Cloud Platform. You need to create OAuth Client ID (ANDROID & WEB), because you will need that same Client ID (WEB), in order to implement One-Tap Sign in with Google.

After that, just call OneTapSignInWithGoogle() function, and pass that same information you've obtained through Google Cloud Platform. You will also pass OneTapSignInState, because that state is used later to trigger One-Tap dialog.

    val state = rememberOneTapSignInState()
    OneTapSignInWithGoogle(
        state = state,
        clientId = "YOUR_CLIENT_ID",
        onTokenIdReceived = { tokenId ->
            Log.d("LOG", tokenId)
        },
        onDialogDismissed = { message ->
            Log.d("LOG", message)
        }
    )

To trigger One-Tap dialog, just call open() function.

Button(onClick = { state.open() }) {
    Text(text = "Sign in")
}

Troubleshoot

In some cases you may encounter "Google Account not Found." message inside onDialogDismiss lambda, even if you have already connected a Google account on your Android Emulator. Android emulators are prone to that issues (Not sure why and when that's gonna get fixed). My suggestion in that case is to try and add a Google account on some other Android Emulator. If that doesn't work either, then use a real device instead.

Like what you see? 💛

⭐ Give a star to this repository.
☕ Buy me a coffee: https://ko-fi.com/stevdza_san

License

Designed and developed by 2022 stevdza-san (Stefan Jovanović)

Licensed 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.

onetapcompose's People

Contributors

stevdza-san avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.