Code Monkey home page Code Monkey logo

googlesignindemo's Introduction

GoogleSignInDemo

Simple Google Sign-In Android Application

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestScopes(new Scope(Scopes.PLUS_LOGIN))
                .requestEmail()
                .build();


mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
                .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
                .addApi(Plus.API)
                .build();

Reference sources:

Try Sign-In for Android

Add Sign-In to your existing app.

Authenticating Your Client

googlesignindemo's People

Contributors

ngocchung avatar

Stargazers

Kelvin Kramp avatar Fatih Akgül avatar  avatar  avatar XC avatar Nammari avatar Cooltao avatar Dion Segijn avatar  avatar Radek Piekarz avatar  avatar Pranav Lathigara avatar

Watchers

James Cloos avatar  avatar

googlesignindemo's Issues

requestCode is 0 for some mobile

Hi,

i have return googlesignin code for my android app but the result code is 0 in public void onActivityResult(int requestCode, int resultCode, Intent data).

below is my code please help.

 googleSignInButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent signInIntent = googleSignInClient.getSignInIntent();
            startActivityForResult(signInIntent, 101);
        }
    });

       @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    System.out.println(">>>>>>>>>>>>> onActivityResult  >>>>>>>>>>> ");
    System.out.println(">>>>>>>>>>>>> Activity  >>>>>>>>>>> "+Activity.RESULT_OK);
    System.out.println(">>>>>>>>>>>>> resultCode  >>>>>>>>>>> "+resultCode);
    System.out.println(">>>>>>>>>>>>> requestCode  >>>>>>>>>>> "+requestCode);
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK)
        switch (requestCode) {
            case 101:
                try {
                    // The Task returned from this call is always completed, no need to attach
                    // a listener.
                    Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
                    GoogleSignInAccount account = task.getResult(ApiException.class);

                    System.out.println(">>>>>>>>>>>>> onActivityResult GoogleSignInAccount >>>>>>>>>>> "+account);
                    onLoggedIn(account);
                } catch (ApiException e) {
                    // The ApiException status code indicates the detailed failure reason.
                    Log.w(TAG, "signInResult:failed code=" + e.getStatusCode());
                }
                break;
        }
}

Google Login Demo

Hello,
I am applying your GoogleSignInDemo and its running successfully but when i am try to get the login user birth date or any other information it always going in else part so i am still unable to get the user gender and birth date.

please reply soon.

untitled

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.