com.google.android.gms.auth.api.signin.GoogleSignInOptions Java Examples
The following examples show how to use
com.google.android.gms.auth.api.signin.GoogleSignInOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GoogleAccountsProvider.java From science-journal with Apache License 2.0 | 9 votes |
public GoogleAccountsProvider(Context context) { super(context); this.context = context; setShowSignInActivityIfNotSignedIn(false); GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build(); googleSignInClient = GoogleSignIn.getClient(context, gso); GoogleSignInAccount googleSignInAccount = GoogleSignIn.getLastSignedInAccount(context); if (googleSignInAccount != null) { signInCurrentAccount(googleSignInAccount); } }
Example #2
Source File: GameSyncService.java From Passbook with Apache License 2.0 | 9 votes |
@Override public SyncService initialize(Activity context) { GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN) .requestScopes(Drive.SCOPE_APPFOLDER) //.requestScopes(Games.SCOPE_GAMES) .build(); mGoogleSignClient = GoogleSignIn.getClient(context, gso); mSignInAccount = GoogleSignIn.getLastSignedInAccount(context); return this; }
Example #3
Source File: SignIn.java From easygoogle with Apache License 2.0 | 6 votes |
@Override public Api.ApiOptions.HasOptions getOptionsFor(Api<? extends Api.ApiOptions> api) { if (Auth.GOOGLE_SIGN_IN_API.equals(api)) { GoogleSignInOptions.Builder googleSignInOptions = new GoogleSignInOptions.Builder( GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail(); // Check server client id for OAuth, so GoogleSignInAccount.getIdToken(); is non-null String serverClientId = getFragment().getServerClientId(); if(serverClientId != null){ googleSignInOptions.requestIdToken(serverClientId); } return googleSignInOptions.build(); } else { return super.getOptionsFor(api); } }
Example #4
Source File: SignInActivity.java From codelab-friendlychat-android with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_in); // Assign fields mSignInButton = (SignInButton) findViewById(R.id.sign_in_button); // Set click listeners mSignInButton.setOnClickListener(this); // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build(); mSignInClient = GoogleSignIn.getClient(this, gso); // Initialize FirebaseAuth mFirebaseAuth = FirebaseAuth.getInstance(); }
Example #5
Source File: MainActivity.java From Android-9-Development-Cookbook with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.signInButton).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { signIn(); } }); GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions .Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build(); mGoogleSignInClient = GoogleSignIn.getClient(this, googleSignInOptions); }
Example #6
Source File: GoogleLoginInstance.java From ShareLoginPayUtil with Apache License 2.0 | 6 votes |
public GoogleLoginInstance(Activity activity, LoginListener listener, boolean fetchUserInfo) { super(activity, listener, fetchUserInfo); mClientId = ShareManager.CONFIG.getGoogleClientId(); mClientSecret = ShareManager.CONFIG.getGoogleClientSecret(); mClient = new OkHttpClient.Builder().build(); GoogleSignInOptions signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(mClientId) .requestScopes(new Scope(Scopes.DRIVE_APPFOLDER), new Scope(Scopes.OPEN_ID), new Scope(Scopes.PLUS_ME)) .requestServerAuthCode(mClientId) .requestProfile() .requestEmail() .build(); mGoogleSignInClient = GoogleSignIn.getClient(activity, signInOptions); }
Example #7
Source File: GoogleApiClientBridge.java From friendspell with Apache License 2.0 | 6 votes |
public String init( Activity activity, GoogleApiClient.ConnectionCallbacks connectedListener, GoogleApiClient.OnConnectionFailedListener connectionFailedListener) { // 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) .requestEmail() .requestId() .requestProfile() .build(); GoogleApiClient googleApiClient = new GoogleApiClient.Builder(activity) .addConnectionCallbacks(connectedListener) .addOnConnectionFailedListener(connectionFailedListener) .addApi(Plus.API) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .addApi(Nearby.MESSAGES_API) .build(); String token = UUID.randomUUID().toString(); clients.put(token, googleApiClient); return token; }
Example #8
Source File: RNGoogleSigninModule.java From google-signin with MIT License | 6 votes |
@ReactMethod public void configure( final ReadableMap config, final Promise promise ) { final ReadableArray scopes = config.hasKey("scopes") ? config.getArray("scopes") : Arguments.createArray(); final String webClientId = config.hasKey("webClientId") ? config.getString("webClientId") : null; final boolean offlineAccess = config.hasKey("offlineAccess") && config.getBoolean("offlineAccess"); final boolean forceCodeForRefreshToken = config.hasKey("forceCodeForRefreshToken") && config.getBoolean("forceCodeForRefreshToken"); final String accountName = config.hasKey("accountName") ? config.getString("accountName") : null; final String hostedDomain = config.hasKey("hostedDomain") ? config.getString("hostedDomain") : null; GoogleSignInOptions options = getSignInOptions(createScopesArray(scopes), webClientId, offlineAccess, forceCodeForRefreshToken, accountName, hostedDomain); _apiClient = GoogleSignIn.getClient(getReactApplicationContext(), options); promise.resolve(null); }
Example #9
Source File: PlayGames.java From shortyz with GNU General Public License v3.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if(thisView != null){ return thisView; } this.mGoogleSignInClient = GoogleSignIn.getClient(this.getContext(), new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN).build()); View v = inflater.inflate(R.layout.slide_playgames, container, false); initView(v); text = (TextView) v.findViewById(R.id.slideText); (this.signInButton = v.findViewById(R.id.sign_in_button)).setOnClickListener(new View.OnClickListener() { public void onClick(View view) { // start the sign-in flow signInSilently(); } }); if(isSignedIn()){ done(); } else { this.signInButton.setVisibility(View.VISIBLE); } return v; }
Example #10
Source File: AuthUtil.java From SEAL-Demo with MIT License | 6 votes |
/** * Allows to logout from Google account * * @param context the activity context */ private static void logoutGoogleProvider(final Context context) { GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(context.getString(R.string.googleClientId)) .requestProfile() .build(); // Build a GoogleSignInClient with the options specified by gso. GoogleSignInClient mGoogleSignInClient = GoogleSignIn.getClient(context, gso); // Check for existing Google Sign In account, if the user is already signed in // the GoogleSignInAccount will be non-null. GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(context); if (account != null) { mGoogleSignInClient.signOut() .addOnCompleteListener(((Activity) context), new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { ApplicationState.setIsKeysCreated(false); // delete all user info deleteUserTokenAndInfo(context); // load sign in Intent myIntent = new Intent(context, SignInActivity.class); ((Activity) context).startActivityForResult(myIntent, SIGN_IN_ACTIVITY_REQUEST_CODE); } }); } }
Example #11
Source File: PlayGameServices.java From PGSGP with MIT License | 6 votes |
private void initializePlayGameServices(boolean enableSaveGamesFunctionality) { GoogleSignInOptions signInOptions = null; if (enableSaveGamesFunctionality) { GoogleSignInOptions.Builder signInOptionsBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN); signInOptionsBuilder.requestScopes(Drive.SCOPE_APPFOLDER).requestId(); signInOptions = signInOptionsBuilder.build(); } else { signInOptions = GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN; } godotCallbacksUtils = new GodotCallbacksUtils(); connectionController = new ConnectionController(appActivity, signInOptions, godotCallbacksUtils); signInController = new SignInController(appActivity, godotCallbacksUtils, connectionController); achievementsController = new AchievementsController(appActivity, connectionController, godotCallbacksUtils); leaderboardsController = new LeaderboardsController(appActivity, godotCallbacksUtils, connectionController); eventsController = new EventsController(appActivity, connectionController, godotCallbacksUtils); playerStatsController = new PlayerStatsController(appActivity, connectionController, godotCallbacksUtils); savedGamesController = new SavedGamesController(appActivity, godotCallbacksUtils, connectionController); googleSignInClient = GoogleSignIn.getClient(appActivity, signInOptions); }
Example #12
Source File: GoogleAuthTest.java From gdx-fireapp with Apache License 2.0 | 6 votes |
@Test public void revokeAccess_fail() { // Given GoogleAuth googleAuth = new GoogleAuth(); Task task = Mockito.mock(Task.class); final Task task2 = Mockito.mock(Task.class); Mockito.when(task2.isSuccessful()).thenReturn(false); Mockito.when(googleSignInClient.revokeAccess()).thenReturn(task); Mockito.when(task.addOnCompleteListener(Mockito.any(OnCompleteListener.class))).thenAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) { ((OnCompleteListener) invocation.getArgument(0)).onComplete(task2); return null; } }); // When FuturePromise promise = (FuturePromise) spy(googleAuth.revokeAccess().silentFail().subscribe()); // Then PowerMockito.verifyStatic(GoogleSignIn.class, VerificationModeFactory.times(1)); GoogleSignIn.getClient((Activity) Mockito.refEq(Gdx.app), Mockito.any(GoogleSignInOptions.class)); Mockito.verify(googleSignInClient, VerificationModeFactory.times(1)).revokeAccess(); // Mockito.verify(promise, VerificationModeFactory.times(1)).doFail(Mockito.nullable(Exception.class)); }
Example #13
Source File: SkeletonActivity.java From android-basic-samples with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the Google API Client with access to Games // Create the client used to sign in. mGoogleSignInClient = GoogleSignIn.getClient(this, GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN); // Setup signin and signout buttons findViewById(R.id.sign_out_button).setOnClickListener(this); findViewById(R.id.sign_in_button).setOnClickListener(this); mDataView = findViewById(R.id.data_view); mTurnTextView = findViewById(R.id.turn_counter_view); checkPlaceholderIds(); }
Example #14
Source File: GoogleApiHelper.java From social-app-android with Apache License 2.0 | 6 votes |
public static GoogleApiClient createGoogleApiClient(FragmentActivity fragmentActivity) { GoogleApiClient.OnConnectionFailedListener failedListener; if (fragmentActivity instanceof GoogleApiClient.OnConnectionFailedListener) { failedListener = (GoogleApiClient.OnConnectionFailedListener) fragmentActivity; } else { throw new IllegalArgumentException(fragmentActivity.getClass().getSimpleName() + " should implement OnConnectionFailedListener"); } GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(fragmentActivity.getResources().getString(R.string.google_web_client_id)) .requestEmail() .build(); return new GoogleApiClient.Builder(fragmentActivity) .enableAutoManage(fragmentActivity, failedListener) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); }
Example #15
Source File: GoogleSignUpActivity.java From socialmediasignup with MIT License | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); String clientId = SocialMediaSignUpUtils.getMetaDataValue(this, getString(R.string.com_ahmedadel_socialmediasignup_googleWebClientId)); GoogleSignInOptions.Builder gsoBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestId() .requestProfile() .requestEmail() .requestIdToken(clientId); setupScopes(gsoBuilder); googleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addConnectionCallbacks(this) .addApi(Auth.GOOGLE_SIGN_IN_API, gsoBuilder.build()) .build(); }
Example #16
Source File: GoogleAuthTest.java From gdx-fireapp with Apache License 2.0 | 6 votes |
@Test public void revokeAccess_ok() { // Given GoogleAuth googleAuth = new GoogleAuth(); Task task = Mockito.mock(Task.class); final Task task2 = Mockito.mock(Task.class); Mockito.when(task2.isSuccessful()).thenReturn(true); Mockito.when(googleSignInClient.revokeAccess()).thenReturn(task); Mockito.when(task.addOnCompleteListener(Mockito.any(OnCompleteListener.class))).thenAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) { ((OnCompleteListener) invocation.getArgument(0)).onComplete(task2); return null; } }); // When FuturePromise promise = (FuturePromise) spy(googleAuth.revokeAccess().subscribe()); // Then PowerMockito.verifyStatic(GoogleSignIn.class, VerificationModeFactory.times(1)); GoogleSignIn.getClient((Activity) Mockito.refEq(Gdx.app), Mockito.any(GoogleSignInOptions.class)); Mockito.verify(googleSignInClient, VerificationModeFactory.times(1)).revokeAccess(); // Mockito.verify(promise, VerificationModeFactory.times(1)).doComplete(Mockito.isNull()); }
Example #17
Source File: MainActivity.java From android-basic-samples with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the client used to sign in. mGoogleSignInClient = GoogleSignIn.getClient(this, GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN); // set up a click listener for everything we care about for (int id : CLICKABLES) { findViewById(id).setOnClickListener(this); } switchToMainScreen(); checkPlaceholderIds(); }
Example #18
Source File: Utils.java From google-signin with MIT License | 6 votes |
static GoogleSignInOptions getSignInOptions( final Scope[] scopes, final String webClientId, final boolean offlineAccess, final boolean forceCodeForRefreshToken, final String accountName, final String hostedDomain ) { GoogleSignInOptions.Builder googleSignInOptionsBuilder = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(new Scope(Scopes.EMAIL), scopes); if (webClientId != null && !webClientId.isEmpty()) { googleSignInOptionsBuilder.requestIdToken(webClientId); if (offlineAccess) { googleSignInOptionsBuilder.requestServerAuthCode(webClientId, forceCodeForRefreshToken); } } if (accountName != null && !accountName.isEmpty()) { googleSignInOptionsBuilder.setAccountName(accountName); } if (hostedDomain != null && !hostedDomain.isEmpty()) { googleSignInOptionsBuilder.setHostedDomain(hostedDomain); } return googleSignInOptionsBuilder.build(); }
Example #19
Source File: LoginActivity.java From NaviBee with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); // setSupportActionBar((Toolbar) findViewById(R.id.login_logo_toolbar)); mAuth = FirebaseAuth.getInstance(); if (!checkSignIn()) { // Configure Google Sign In GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build(); // Build a GoogleSignInClient with the options specified by gso. mGoogleSignInClient = GoogleSignIn.getClient(this, gso); findViewById(R.id.sign_in_button).setOnClickListener(this); } }
Example #20
Source File: LoginActivity.java From aptoide-client with GNU General Public License v2.0 | 6 votes |
private void setUpGoogle() { final View googleSignIn = findViewById(R.id.g_sign_in_button); final int connectionResult = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this); final Collection<Integer> badResults = Arrays.asList(ConnectionResult.SERVICE_MISSING, ConnectionResult.SERVICE_DISABLED); final boolean gmsAvailable = BuildConfig.GMS_CONFIGURED && !badResults.contains(connectionResult); if (!gmsAvailable) { googleSignIn.setVisibility(View.GONE); return; } final GoogleSignInOptions gso = new GoogleSignInOptions .Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .requestServerAuthCode(BuildConfig.GMS_SERVER_ID) .build(); final GoogleApiClient client = new GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); googleSignIn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(client); startActivityForResult(signInIntent, REQ_SIGN_IN_GOOGLE); } }); }
Example #21
Source File: Home.java From UberClone with MIT License | 6 votes |
private void verifyGoogleAccount() { GoogleSignInOptions gso=new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build(); mGoogleApiClient=new GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); OptionalPendingResult<GoogleSignInResult> opr=Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient); if (opr.isDone()){ GoogleSignInResult result= opr.get(); handleSignInResult(result); }else { opr.setResultCallback(new ResultCallback<GoogleSignInResult>() { @Override public void onResult(@NonNull GoogleSignInResult googleSignInResult) { handleSignInResult(googleSignInResult); } }); } }
Example #22
Source File: GoogleLoginHiddenActivity.java From SocialLoginManager with Apache License 2.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestId() .requestProfile() .requestIdToken(getIntent().getStringExtra(EXTRA_CLIENT_ID)) .requestEmail() .build(); GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this, this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN); }
Example #23
Source File: LoadingActivity.java From PretendYoureXyzzyAndroid with GNU General Public License v3.0 | 6 votes |
private void signInSilently() { GoogleSignInOptions signInOptions = GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN; GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this); if (GoogleSignIn.hasPermissions(account, signInOptions.getScopeArray())) { googleSignedIn(account); } else { GoogleSignInClient signInClient = GoogleSignIn.getClient(this, signInOptions); signInClient.silentSignIn().addOnCompleteListener(this, task -> { if (task.isSuccessful()) { googleSignedIn(task.getResult()); } else { if (Prefs.getBoolean(PK.SHOULD_PROMPT_GOOGLE_PLAY, true)) { Intent intent = signInClient.getSignInIntent(); startActivityForResult(intent, GOOGLE_SIGN_IN_CODE); } } }); } }
Example #24
Source File: SignInActivity.java From jterm-cswithandroid with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sign_in); // Assign fields mSignInButton = (SignInButton) findViewById(R.id.sign_in_button); // Set click listeners mSignInButton.setOnClickListener(this); // Configure Google Sign In 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 /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); // Initialize FirebaseAuth mFirebaseAuth = FirebaseAuth.getInstance(); }
Example #25
Source File: GoogleSignInOptionsFactory.java From gdx-fireapp with Apache License 2.0 | 5 votes |
static GoogleSignInOptions factory() { String webClientId = StringResource.getStringResourceByName("default_web_client_id"); return new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(webClientId) .requestEmail() .build(); }
Example #26
Source File: RestApiActivity.java From google-services with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Views mStatusTextView = findViewById(R.id.status); mDetailTextView = findViewById(R.id.detail); // Button listeners findViewById(R.id.sign_in_button).setOnClickListener(this); findViewById(R.id.sign_out_button).setOnClickListener(this); // For this example we don't need the disconnect button findViewById(R.id.disconnect_button).setVisibility(View.GONE); // Restore instance state if (savedInstanceState != null) { mAccount = savedInstanceState.getParcelable(KEY_ACCOUNT); } // Configure sign-in to request the user's ID, email address, basic profile, // and readonly access to contacts. GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(new Scope(CONTACTS_SCOPE)) .requestEmail() .build(); mGoogleSignInClient = GoogleSignIn.getClient(this, gso); // Show a standard Google Sign In button. If your application does not rely on Google Sign // In for authentication you could replace this with a "Get Google Contacts" button // or similar. SignInButton signInButton = findViewById(R.id.sign_in_button); signInButton.setSize(SignInButton.SIZE_STANDARD); }
Example #27
Source File: GoogleAuthTest.java From gdx-fireapp with Apache License 2.0 | 5 votes |
@Test public void signIn() { // Given // mock GoogleSignInOptions? GoogleAuth googleAuth = new GoogleAuth(); // When googleAuth.signIn().subscribe(); // Then Mockito.verify(((AndroidApplication) Gdx.app), VerificationModeFactory.times(1)).startActivityForResult(Mockito.nullable(Intent.class), Mockito.anyInt()); PowerMockito.verifyStatic(GoogleSignIn.class, VerificationModeFactory.times(1)); GoogleSignIn.getClient((Activity) Mockito.refEq(Gdx.app), Mockito.any(GoogleSignInOptions.class)); }
Example #28
Source File: GoogleHelper.java From argus-android with Apache License 2.0 | 5 votes |
/** * Initializing google api client if no client id provided * It will throw null pointer exception while requesting Id token from GoogleSignInAccount */ public void initializeGoogleApiClient() { GoogleSignInOptions gso = new GoogleSignInOptions.Builder( GoogleSignInOptions.DEFAULT_SIGN_IN) .requestProfile() .requestEmail() .build(); googleApiClient = new GoogleApiClient.Builder(fragment.getContext()) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); }
Example #29
Source File: PlayGames.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
public void connect() { if(isConnected() || connecting) { return; } connecting = true; GoogleSignInOptions signInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN) .requestScopes(Games.SCOPE_GAMES_SNAPSHOTS) .build(); GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(Game.instance()); if (GoogleSignIn.hasPermissions(account, signInOptions.getScopeArray())) { signedInAccount = account; onConnected(); } else { GoogleSignIn.getClient(Game.instance(), signInOptions) .silentSignIn() .addOnCompleteListener( Game.instance().serviceExecutor, task -> { if (task.isSuccessful()) { signedInAccount = task.getResult(); onConnected(); } else { //Preferences.INSTANCE.put(Preferences.KEY_USE_PLAY_GAMES, false); } }); } }
Example #30
Source File: DriveSyncService.java From Passbook with Apache License 2.0 | 5 votes |
@Override public SyncService initialize(Activity context) { GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestScopes(Drive.SCOPE_APPFOLDER).build(); mGoogleSignClient = GoogleSignIn.getClient(context, gso); mSignInAccount = GoogleSignIn.getLastSignedInAccount(context); return this; }