use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project easy by MehdiBenmesa.
the class IdTokenActivity method refreshIdToken.
private void refreshIdToken() {
OptionalPendingResult<GoogleSignInResult> opr = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (opr.isDone()) {
// Users cached credentials are valid, GoogleSignInResult containing ID token
// is available immediately. This likely means the current ID token is already
// fresh and can be sent to your server.
GoogleSignInResult result = opr.get();
handleSignInResult(result);
} else {
// If the user has not previously signed in on this device or the sign-in has expired,
// this asynchronous branch will attempt to sign in the user silently and get a valid
// ID token. Cross-device single sign on will occur in this branch.
opr.setResultCallback(new ResultCallback<GoogleSignInResult>() {
@Override
public void onResult(@NonNull GoogleSignInResult result) {
handleSignInResult(result);
}
});
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project Android-SDK by Backendless.
the class LoginWithGooglePlusSDKActivity 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) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project Passenger_Security by ujjwalagr.
the class GoogleLogin method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQ_CODE) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleresult(result);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project iosched by google.
the class SignInManager method onActivityResult.
/**
* Method for processing sign in logic in the bonding activity's
* {@link Activity#onActivityResult(int, int, Intent)}.
*
* @param requestCode The requestCode argument of the activity's onActivityResult.
* @param resultCode The resultCode argument of the activity's onActivityResult.
* @param data The Intent argument of the activity's onActivityResult.
*/
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
final SignInListener signInListener = getSignInListener();
if (signInListener == null) {
return;
}
if (requestCode == AccountUtils.RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
if (acct != null) {
performPostSignInTasks(acct, result);
}
} else {
LOGW(TAG, "Sign in failed");
signInListener.onSignInFailed(result);
}
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInResult in project androidApp by InspectorIncognito.
the class GoogleAccountLoader method load.
@Override
public void load(final CredentialsListener listener) {
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().requestIdToken(TranSappApplication.getAppContext().getString(R.string.server_client_id)).build();
final GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(TranSappApplication.getAppContext()).addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
mGoogleApiClient.registerConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(@Nullable Bundle bundle) {
OptionalPendingResult<GoogleSignInResult> pendingResult = Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (pendingResult.isDone()) {
loadDataFromSignInResult(pendingResult.get(), listener, mGoogleApiClient);
} else {
pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
@Override
public void onResult(@NonNull GoogleSignInResult result) {
if (result.isSuccess()) {
loadDataFromSignInResult(result, listener, mGoogleApiClient);
} else {
listener.onError(new ServerStatusCode(LOGIN_API_ERROR));
}
}
}, 5000, TimeUnit.MILLISECONDS);
}
}
@Override
public void onConnectionSuspended(int i) {
listener.onError(new ServerStatusCode(LOGIN_API_ERROR));
}
});
mGoogleApiClient.connect();
}
Aggregations