Search in sources :

Example 6 with GoogleSignInOptions

use of com.google.android.gms.auth.api.signin.GoogleSignInOptions in project RSAndroidApp by RailwayStations.

the class SignInActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_in);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Assign fields
    mSignInButton = (SignInButton) findViewById(R.id.sign_in_button);
    // Set click listeners
    mSignInButton.setOnClickListener(this);
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build();
    mGoogleApiClient = new GoogleApiClient.Builder(this).enableAutoManage(this, /* FragmentActivity */
    this).addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
    // Initialize FirebaseAuth
    mFirebaseAuth = FirebaseAuth.getInstance();
}
Also used : GoogleSignInOptions(com.google.android.gms.auth.api.signin.GoogleSignInOptions)

Example 7 with GoogleSignInOptions

use of com.google.android.gms.auth.api.signin.GoogleSignInOptions in project Android by Tracman-org.

the class LoginActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //Log.v(TAG, "created");
    // Set up layout
    setContentView(R.layout.activity_login);
    setTitle(R.string.login_name);
    TextView loginDescription = (TextView) findViewById(R.id.login_description);
    TextView forgotPassword = (TextView) findViewById(R.id.login_forgot_password);
    loginDescription.setMovementMethod(LinkMovementMethod.getInstance());
    forgotPassword.setMovementMethod(LinkMovementMethod.getInstance());
    // Configure sign-in to request the user's ID and basic profile, included in DEFAULT_SIGN_IN.
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken(GOOGLE_WEB_CLIENT_ID).requestEmail().build();
    // Build a GoogleApiClient with access to the Google Sign-In API and the
    // options specified by gso.
    mGoogleApiClient = new GoogleApiClient.Builder(this).enableAutoManage(this, /* FragmentActivity */
    this).addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
    // Set up buttons
    SignInButton signInButton = (SignInButton) findViewById(R.id.login_button_google);
    signInButton.setStyle(SignInButton.SIZE_WIDE, SignInButton.COLOR_AUTO);
    // Button listeners
    findViewById(R.id.login_button).setOnClickListener(this);
    findViewById(R.id.login_button_google).setOnClickListener(this);
//		findViewById(R.id.login_button_facebook).setOnClickListener(this);
//		findViewById(R.id.login_button_twitter).setOnClickListener(this);
}
Also used : SignInButton(com.google.android.gms.common.SignInButton) TextView(android.widget.TextView) GoogleSignInOptions(com.google.android.gms.auth.api.signin.GoogleSignInOptions)

Example 8 with GoogleSignInOptions

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

the class GoogleSignInActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_google);
    // Views
    mStatusTextView = (TextView) findViewById(R.id.status);
    mDetailTextView = (TextView) findViewById(R.id.detail);
    // Button listeners
    findViewById(R.id.sign_in_button).setOnClickListener(this);
    findViewById(R.id.sign_out_button).setOnClickListener(this);
    findViewById(R.id.disconnect_button).setOnClickListener(this);
    // [START config_signin]
    // Configure Google Sign In
    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestIdToken(getString(R.string.default_web_client_id)).requestEmail().build();
    // [END config_signin]
    mGoogleApiClient = new GoogleApiClient.Builder(this).enableAutoManage(this, /* FragmentActivity */
    this).addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
    // [START initialize_auth]
    mAuth = FirebaseAuth.getInstance();
    // [END initialize_auth]
    // [START auth_state_listener]
    mAuthListener = new FirebaseAuth.AuthStateListener() {

        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            FirebaseUser user = firebaseAuth.getCurrentUser();
            if (user != null) {
                // User is signed in
                Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
            } else {
                // User is signed out
                Log.d(TAG, "onAuthStateChanged:signed_out");
            }
            // [START_EXCLUDE]
            updateUI(user);
        // [END_EXCLUDE]
        }
    };
// [END auth_state_listener]
}
Also used : GoogleSignInOptions(com.google.android.gms.auth.api.signin.GoogleSignInOptions) FirebaseUser(com.google.firebase.auth.FirebaseUser) FirebaseAuth(com.google.firebase.auth.FirebaseAuth)

Example 9 with GoogleSignInOptions

use of com.google.android.gms.auth.api.signin.GoogleSignInOptions in project iosched by google.

the class SwitchUserActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Configure Google API client for use with login API
    GoogleSignInOptions.Builder gsoBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN);
    for (String scope : LoginAndAuthWithGoogleApi.GetAuthScopes()) {
        gsoBuilder.requestScopes(new Scope(scope));
    }
    GoogleSignInOptions gso = gsoBuilder.requestEmail().build();
    mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Auth.GOOGLE_SIGN_IN_API, gso).addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();
    mGoogleApiClient.connect();
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) Scope(com.google.android.gms.common.api.Scope) GoogleSignInOptions(com.google.android.gms.auth.api.signin.GoogleSignInOptions)

Example 10 with GoogleSignInOptions

use of com.google.android.gms.auth.api.signin.GoogleSignInOptions in project iosched by google.

the class AccountFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    // Inflate the layout for this fragment
    mLayout = inflater.inflate(R.layout.welcome_account_fragment, container, false);
    if (mActivity instanceof WelcomeFragmentContainer) {
        ((WelcomeFragmentContainer) mActivity).setPrimaryButtonEnabled(false);
    }
    // Configure Google API client for use with login API
    GoogleSignInOptions.Builder gsoBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN);
    for (String scope : LoginAndAuthWithGoogleApi.GetAuthScopes()) {
        gsoBuilder.requestScopes(new Scope(scope));
    }
    GoogleSignInOptions gso = gsoBuilder.requestEmail().build();
    mGoogleApiClient = new GoogleApiClient.Builder(getContext()).addApi(Auth.GOOGLE_SIGN_IN_API, gso).addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();
    mGoogleApiClient.connect();
    return mLayout;
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) Scope(com.google.android.gms.common.api.Scope) GoogleSignInOptions(com.google.android.gms.auth.api.signin.GoogleSignInOptions)

Aggregations

GoogleSignInOptions (com.google.android.gms.auth.api.signin.GoogleSignInOptions)16 Scope (com.google.android.gms.common.api.Scope)8 SignInButton (com.google.android.gms.common.SignInButton)6 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)3 TextView (android.widget.TextView)1 FirebaseAuth (com.google.firebase.auth.FirebaseAuth)1 FirebaseUser (com.google.firebase.auth.FirebaseUser)1