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();
}
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);
}
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]
}
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();
}
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;
}
Aggregations