use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project easy by MehdiBenmesa.
the class RestApiActivity method handleSignInResult.
private void handleSignInResult(GoogleSignInResult result) {
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Get the account from the sign in result
GoogleSignInAccount account = result.getSignInAccount();
// Signed in successfully, show authenticated UI.
mStatusTextView.setText(getString(R.string.signed_in_fmt, account.getDisplayName()));
updateUI(true);
// Store the account from the result
mAccount = account.getAccount();
// Asynchronously access the People API for the account
getContacts();
} else {
// Clear the local account
mAccount = null;
// Signed out, show unauthenticated UI.
updateUI(false);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project easy by MehdiBenmesa.
the class StartActivity method handleSignInResult.
// [END onActivityResult]
//1D:80:89:02:65:1A:38:03:60:08:D1:38:24:EA:CA:C0:F9:59:48:AC
// [START handleSignInResult]
private void handleSignInResult(GoogleSignInResult result) {
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
GoogleSignInAccount acct = result.getSignInAccount();
updateUI(true);
App.getInstance().setAccessToken(acct.getIdToken());
App.getInstance().setEmail(acct.getEmail());
if (acct.getEmail().substring(acct.getEmail().length() - 6, acct.getEmail().length()).equals("esi.dz")) {
CustomRequest jsonReq = new CustomRequest(Request.Method.POST, APP_LOGIN, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONObject user = response.getJSONObject("user");
Log.i(TAG, "Signed in as: " + user.getString("name"));
//JSONArray resp = responseBody.to;
if (user.getString("mail").equals(App.getInstance().getEmail())) {
startUserActivity(user);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
hidepDialog();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("email", App.getInstance().getEmail());
params.put("idToken", App.getInstance().getAccessToken());
return params;
}
};
App.getInstance().addToRequestQueue(jsonReq);
} else {
String msg = "c'est pas un compte ESI ";
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
}
} else {
// Signed out, show unauthenticated UI.
updateUI(false);
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project easy by MehdiBenmesa.
the class ServerAuthCodeActivity method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_GET_AUTH_CODE) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
Log.d(TAG, "onActivityResult:GET_AUTH_CODE:success:" + result.getStatus().isSuccess());
if (result.isSuccess()) {
// [START get_auth_code]
GoogleSignInAccount acct = result.getSignInAccount();
String authCode = acct.getServerAuthCode();
// Show signed-in UI.
mAuthCodeTextView.setText(getString(R.string.auth_code_fmt, authCode));
updateUI(true);
// TODO(user): send code to server and exchange for access/refresh/ID tokens.
// [END get_auth_code]
} else {
// Show signed-out UI.
updateUI(false);
}
}
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project xabber-android by redsolution.
the class BaseLoginActivity method handleSignInResult.
private void handleSignInResult(GoogleSignInResult result) {
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
if (acct != null) {
final String googleAuthCode = acct.getServerAuthCode();
Application.getInstance().runInBackground(new Runnable() {
@Override
public void run() {
try {
GoogleTokenResponse tokenResponse = new GoogleAuthorizationCodeTokenRequest(new NetHttpTransport(), JacksonFactory.getDefaultInstance(), GOOGLE_TOKEN_SERVER, getString(R.string.SOCIAL_AUTH_GOOGLE_KEY), getString(R.string.SOCIAL_AUTH_GOOGLE_SECRET), googleAuthCode, "").execute();
final String token = tokenResponse.getAccessToken();
Application.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
loginSocial(AuthManager.PROVIDER_GOOGLE, token);
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
} else
Toast.makeText(this, "google error", Toast.LENGTH_LONG).show();
}
use of com.google.android.gms.auth.api.signin.GoogleSignInAccount in project google-services by googlesamples.
the class SignInActivity method handleSignInResult.
// [END onActivityResult]
// [START handleSignInResult]
private void handleSignInResult(GoogleSignInResult result) {
Log.d(TAG, "handleSignInResult:" + result.isSuccess());
if (result.isSuccess()) {
// Signed in successfully, show authenticated UI.
GoogleSignInAccount acct = result.getSignInAccount();
mStatusTextView.setText(getString(R.string.signed_in_fmt, acct.getDisplayName()));
updateUI(true);
} else {
// Signed out, show unauthenticated UI.
updateUI(false);
}
}
Aggregations