Java Code Examples for com.google.android.gms.auth.api.signin.GoogleSignInAccount#getPhotoUrl()

The following examples show how to use com.google.android.gms.auth.api.signin.GoogleSignInAccount#getPhotoUrl() . 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: GoogleLoginHiddenActivity.java    From SocialLoginManager with Apache License 2.0 6 votes vote down vote up
private void handleSignInResult(GoogleSignInResult result) {
  if (result.isSuccess()) {
    GoogleSignInAccount acct = result.getSignInAccount();
    SocialUser user = new SocialUser();
    user.userId = acct.getId();
    user.accessToken = acct.getIdToken();
    user.photoUrl = acct.getPhotoUrl() != null ? acct.getPhotoUrl().toString() : "";
    SocialUser.Profile profile = new SocialUser.Profile();
    profile.email = acct.getEmail();
    profile.name = acct.getDisplayName();
    user.profile = profile;
    SocialLoginManager.getInstance(this).onLoginSuccess(user);
  } else {
    Throwable throwable = new Throwable(result.getStatus().getStatusMessage());
    SocialLoginManager.getInstance(this).onLoginError(throwable);
  }

  finish();
}
 
Example 2
Source File: UserUtil.java    From Android-Smart-Login with Apache License 2.0 6 votes vote down vote up
public static SmartGoogleUser populateGoogleUser(GoogleSignInAccount account){
    //Create a new google user
    SmartGoogleUser googleUser = new SmartGoogleUser();
    //populate the user
    googleUser.setDisplayName(account.getDisplayName());
    if (account.getPhotoUrl() != null) {
        googleUser.setPhotoUrl(account.getPhotoUrl().toString());
    }
    googleUser.setEmail(account.getEmail());
    googleUser.setIdToken(account.getIdToken());
    googleUser.setUserId(account.getId());
    if (account.getAccount() != null) {
        googleUser.setUsername(account.getAccount().name);
    }

    //return the populated google user
    return googleUser;
}
 
Example 3
Source File: Utils.java    From google-signin with MIT License 6 votes vote down vote up
static WritableMap getUserProperties(@NonNull GoogleSignInAccount acct) {
    Uri photoUrl = acct.getPhotoUrl();

    WritableMap user = Arguments.createMap();
    user.putString("id", acct.getId());
    user.putString("name", acct.getDisplayName());
    user.putString("givenName", acct.getGivenName());
    user.putString("familyName", acct.getFamilyName());
    user.putString("email", acct.getEmail());
    user.putString("photo", photoUrl != null ? photoUrl.toString() : null);

    WritableMap params = Arguments.createMap();
    params.putMap("user", user);
    params.putString("idToken", acct.getIdToken());
    params.putString("serverAuthCode", acct.getServerAuthCode());

    WritableArray scopes = Arguments.createArray();
    for (Scope scope : acct.getGrantedScopes()) {
        String scopeString = scope.toString();
        if (scopeString.startsWith("http")) {
            scopes.pushString(scopeString);
        }
    }
    params.putArray("scopes", scopes);
    return params;
}
 
Example 4
Source File: AndroidGoogleAccount.java    From QtAndroidTools with MIT License 5 votes vote down vote up
private boolean loadSignedInAccountInfo(final GoogleSignInAccount SignedInAccount)
{
    if(SignedInAccount != null)
    {
        AccountInfo SignedInAccountInfo = new AccountInfo();
        final Uri PhotoUrl = SignedInAccount.getPhotoUrl();

        SignedInAccountInfo.id = SignedInAccount.getId();
        SignedInAccountInfo.displayName = SignedInAccount.getDisplayName();
        SignedInAccountInfo.email = SignedInAccount.getEmail();
        SignedInAccountInfo.familyName = SignedInAccount.getFamilyName();
        SignedInAccountInfo.givenName = SignedInAccount.getGivenName();

        if(PhotoUrl != null)
        {
            DownloadAccountPhotoTask DownloadAccountPhoto = new DownloadAccountPhotoTask(SignedInAccountInfo);
            DownloadAccountPhoto.execute(PhotoUrl.toString());
        }
        else
        {
            SignedInAccountInfo.photo = null;
            updateSignedInAccountInfo(SignedInAccountInfo);
        }

        return true;
    }

    return false;
}
 
Example 5
Source File: RxAccount.java    From RxSocialAuth with Apache License 2.0 5 votes vote down vote up
public RxAccount(GoogleSignInAccount gsa) {
    this.id = gsa.getId();
    this.accessToken = gsa.getIdToken();
    this.email = gsa.getEmail();
    this.firstname = gsa.getGivenName();
    this.lastname = gsa.getFamilyName();
    this.displayName = gsa.getDisplayName();
    this.photoUri = gsa.getPhotoUrl();
    this.provider = IdentityProviders.GOOGLE;
}