Search in sources :

Example 36 with GoogleSignInAccount

use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project YourAppIdea by Michenux.

the class GoogleAuthDelegate method handleSignInResult.

private void handleSignInResult(GoogleSignInResult result) {
    if (BuildConfig.DEBUG) {
        Log.d(MCXApplication.LOG_TAG, "handleSignInResult:" + result.isSuccess() + " " + result.getStatus().getStatusCode() + result.getStatus().hasResolution());
    }
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        GoogleSignInAccount acct = result.getSignInAccount();
        User user = new User();
        user.setProvider(PROVIDER_NAME);
        user.setProviderDisplayName("Google+");
        user.setUserId(acct.getId());
        user.setUserName(acct.getId());
        user.setDisplayName(acct.getDisplayName());
        user.setMail(acct.getEmail());
        this.mUserHelper.setCurrentUser(user);
        if (this.mUserSessionCallback != null) {
            this.mUserSessionCallback.onLogin();
        }
    } else {
        // Signed out, show unauthenticated UI.
        this.mUserSessionCallback.onLogout();
    }
}
Also used : User(org.michenux.drodrolib.security.User) GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount)

Example 37 with GoogleSignInAccount

use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project quickstart-android by firebase.

the class GoogleSignInFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
    if (requestCode == RC_SIGN_IN) {
        Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {
            // Google Sign In was successful, authenticate with Firebase
            GoogleSignInAccount account = task.getResult(ApiException.class);
            Log.d(TAG, "firebaseAuthWithGoogle:" + account.getId());
            firebaseAuthWithGoogle(account.getIdToken());
        } catch (ApiException e) {
            // Google Sign In failed, update UI appropriately
            Log.w(TAG, "Google sign in failed", e);
            updateUI(null);
        }
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) ApiException(com.google.android.gms.common.api.ApiException)

Example 38 with GoogleSignInAccount

use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project Andela-Med-Manager by jumaallan.

the class AuthActivity method handleSignInResult.

private void handleSignInResult(GoogleSignInResult result) {
    Timber.d("handleSignInResult:" + result.isSuccess() + " " + result.getStatus());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        GoogleSignInAccount acct = result.getSignInAccount();
        assert acct != null;
        String name = acct.getDisplayName();
        String imageUrl = String.valueOf(acct.getPhotoUrl());
        /*
             * Save to Room DB
             * Set the Logged in status to true
             * Navigate user to Main Activity
             */
        addUserViewModel.addUser(new User("1", name, imageUrl));
        Settings.setLoggedInSharedPref(true);
        Intent intent = new Intent(getApplicationContext(), MainActivity.class);
        startActivity(intent);
        finish();
    }
}
Also used : User(com.androidstudy.andelamedmanager.data.model.User) GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) Intent(android.content.Intent)

Example 39 with GoogleSignInAccount

use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project AndelaMedManager by jumaallan.

the class AuthActivity method handleSignInResult.

private void handleSignInResult(GoogleSignInResult result) {
    Timber.d("handleSignInResult:" + result.isSuccess() + " " + result.getStatus());
    if (result.isSuccess()) {
        // Signed in successfully, show authenticated UI.
        GoogleSignInAccount acct = result.getSignInAccount();
        assert acct != null;
        String name = acct.getDisplayName();
        String imageUrl = String.valueOf(acct.getPhotoUrl());
        /*
             * Save to Room DB
             * Set the Logged in status to true
             * Navigate user to Main Activity
             */
        addUserViewModel.addUser(new User("1", name, imageUrl));
        Settings.setLoggedInSharedPref(true);
        Intent intent = new Intent(getApplicationContext(), MainActivity.class);
        startActivity(intent);
        finish();
    }
}
Also used : User(com.androidstudy.andelamedmanager.data.model.User) GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) Intent(android.content.Intent)

Example 40 with GoogleSignInAccount

use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project Passenger_Security by ujjwalagr.

the class GoogleLogin method handleresult.

private void handleresult(GoogleSignInResult result) {
    if (result.isSuccess()) {
        GoogleSignInAccount account = result.getSignInAccount();
        nameget = account.getDisplayName();
        emailget = account.getEmail();
        img_url = account.getPhotoUrl().toString();
        Toast.makeText(this, "Welcome " + nameget, Toast.LENGTH_SHORT).show();
        Intent intent = new Intent(GoogleLogin.this, HomeScreen.class);
        intent.putExtra("name", nameget).putExtra("urlimg", img_url).putExtra("email", emailget);
        startActivity(intent);
        finish();
    } else {
        Toast.makeText(this, "Unsuccessful login", Toast.LENGTH_SHORT).show();
    }
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) Intent(android.content.Intent)

Aggregations

GoogleSignInAccount (com.google.android.gms.auth.api.signin.GoogleSignInAccount)48 ApiException (com.google.android.gms.common.api.ApiException)15 GoogleSignInResult (com.google.android.gms.auth.api.signin.GoogleSignInResult)12 Intent (android.content.Intent)7 IOException (java.io.IOException)5 User (com.androidstudy.andelamedmanager.data.model.User)2 GoogleSignInOptions (com.google.android.gms.auth.api.signin.GoogleSignInOptions)2 Scope (com.google.android.gms.common.api.Scope)2 Request (okhttp3.Request)2 JSONException (org.json.JSONException)2 Context (android.content.Context)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 NonNull (androidx.annotation.NonNull)1 ServerStatusCode (cl.smartcities.isci.transportinspector.serverConnection.ServerStatusCode)1 Response (com.android.volley.Response)1 VolleyError (com.android.volley.VolleyError)1 IntentResultListener (com.codename1.impl.android.IntentResultListener)1 AccessToken (com.codename1.io.AccessToken)1 ConnectionRequest (com.codename1.io.ConnectionRequest)1