Gmail subscribes to the integration into the android application, is profilePhoto always null?

We have included Gmail in our Android application, we use server integration to get auth_code once, as indicated here: https://developers.google.com/identity/sign-in/android/offline-access

We get access to the Gmail account both on the server and on the Android device in our application.

But for some reason we don’t get a profile photo using the method below:

googleSignInAccount.getPhotoUrl();

In the process of requesting a request, we use the following code:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                        .requestScopes(new Scope(GmailScopes.GMAIL_READONLY))
                        .requestServerAuthCode("OUR_SERVER_CLIET_ID", true)
                        .requestEmail()
                        .requestProfile()
                        .build();

stackoverflow , Google+ , URL- . , , Google+.

, iOS, URL ? ?

:

, , , url.

+6
3

:

, , , url.

0

, , email, displayname, photourl

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();
            mGoogleApiClient = new GoogleApiClient.Builder(mContext).enableAutoManage((AppCompatActivity) activity, new GoogleApiClient.OnConnectionFailedListener() {
                @Override
                public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {

                }
            }).addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();
            Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
            startActivityForResult(signInIntent,1);

onActivityResult acct

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
            if (result.isSuccess()) {
                GoogleSignInAccount acct = result.getSignInAccount();
                mGoogleApiClient.stopAutoManage((AppCompatActivity) activity);
                mGoogleApiClient.disconnect();
                Log.e("user_id",acct.getId());
                Log.e("user_id",acct.getEmail());
                Log.e("user_id",acct.getDisplayName());
                Log.e("image_url",String.valueOf(acct.getPhotoUrl()));
        }
    }

googlesignin .

0

If any user does not set any pic profile, it will always be null. therefore you need to process this script in your application.

if(acct.getPhotoUrl()!=null)
{
   personPhotoUrl = acct.getPhotoUrl().toString();
}
0
source

Source: https://habr.com/ru/post/1016771/


All Articles