use of com.google.android.gms.common.api.Scope in project FirebaseUI-Android by firebase.
the class GoogleProvider method getSignInOptions.
private GoogleSignInOptions getSignInOptions(@Nullable String email) {
String clientId = mActivity.getString(R.string.default_web_client_id);
GoogleSignInOptions.Builder builder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().requestIdToken(clientId);
if (mActivity.getResources().getIdentifier("google_permissions", "array", mActivity.getPackageName()) != 0) {
Log.w(TAG, "DEVELOPER WARNING: You have defined R.array.google_permissions but that is" + " no longer respected as of FirebaseUI 1.0.0. Please see README for IDP scope" + " configuration instructions.");
}
// Add additional scopes
for (String scopeString : mIdpConfig.getScopes()) {
builder.requestScopes(new Scope(scopeString));
}
if (!TextUtils.isEmpty(email)) {
builder.setAccountName(email);
}
return builder.build();
}
use of com.google.android.gms.common.api.Scope in project google-services by googlesamples.
the class MainActivity method onCreate.
// [END resolution_variables]
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// [START restore_saved_instance_state]
if (savedInstanceState != null) {
mIsResolving = savedInstanceState.getBoolean(KEY_IS_RESOLVING);
mShouldResolve = savedInstanceState.getBoolean(KEY_SHOULD_RESOLVE);
}
// [END restore_saved_instance_state]
// Set up button click listeners
findViewById(R.id.sign_in_button).setOnClickListener(this);
findViewById(R.id.sign_out_button).setOnClickListener(this);
findViewById(R.id.disconnect_button).setOnClickListener(this);
// Large sign-in
((SignInButton) findViewById(R.id.sign_in_button)).setSize(SignInButton.SIZE_WIDE);
// Start with sign-in button disabled until sign-in either succeeds or fails
findViewById(R.id.sign_in_button).setEnabled(false);
// Set up view instances
mStatus = (TextView) findViewById(R.id.status);
// [START create_google_api_client]
// Build GoogleApiClient with access to basic profile
mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(this).addApi(Plus.API).addScope(new Scope(Scopes.PROFILE)).addScope(new Scope(Scopes.EMAIL)).build();
// [END create_google_api_client]
}
use of com.google.android.gms.common.api.Scope in project google-services by googlesamples.
the class SignInActivityWithDrive method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Views
mStatusTextView = (TextView) findViewById(R.id.status);
// 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 configure_signin]
// Configure sign-in to request the user's ID, email address, and basic
// profile. ID and basic profile are included in DEFAULT_SIGN_IN.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestScopes(new Scope(Scopes.DRIVE_APPFOLDER)).requestEmail().build();
// [END configure_signin]
// [START build_client]
// 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();
// [END build_client]
// [START customize_button]
// Customize sign-in button. The sign-in button can be displayed in
// multiple sizes and color schemes. It can also be contextually
// rendered based on the requested scopes. For example. a red button may
// be displayed when Google+ scopes are requested, but a white button
// may be displayed when only basic profile is requested. Try adding the
// Scopes.PLUS_LOGIN scope to the GoogleSignInOptions to see the
// difference.
SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button);
signInButton.setSize(SignInButton.SIZE_STANDARD);
signInButton.setScopes(gso.getScopeArray());
// [END customize_button]
}
use of com.google.android.gms.common.api.Scope in project iosched by google.
the class LoginAndAuthWithGoogleApi method start.
/**
* Starts the helper. Call this from your Activity's onStart().
*/
@Override
public void start() {
Activity activity = getActivity("start()");
if (activity == null) {
return;
}
if (mStarted) {
LOGW(TAG, "Helper already started. Ignoring redundant call.");
return;
}
mStarted = true;
if (mResolving) {
// if resolving, don't reconnect the plus client
LOGD(TAG, "Helper ignoring signal to start because we're resolving a failure.");
return;
}
LOGD(TAG, "Helper starting. Connecting " + mAccountName);
if (mGoogleApiClient == null) {
LOGD(TAG, "Creating client.");
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(activity);
for (String scope : AUTH_SCOPES) {
builder.addScope(new Scope(scope));
}
mGoogleApiClient = builder.addApi(Plus.API).addConnectionCallbacks(this).addOnConnectionFailedListener(this).setAccountName(mAccountName).build();
}
LOGD(TAG, "Connecting client.");
mGoogleApiClient.connect();
}
use of com.google.android.gms.common.api.Scope 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();
}
Aggregations