Retrieving user display name after Google Drive API authorization with new auth system

I’m working on updating my app to use the newer authorization approach instead of the old Google Sign-In method. Everything works fine for accessing Google Drive, but I can’t figure out how to get the user’s name to display in my app.

I’ve been through tons of documentation and forum posts about this issue. Based on what I found, it seems like for Google Drive access you don’t need full authentication - just authorization using the Authorization API should be enough.

I’m requesting multiple scopes to try to get user info:

ArrayList<Scope> neededScopes = new ArrayList<>();
neededScopes.add(new Scope(DriveScopes.DRIVE_FILE));
neededScopes.add(new Scope(Scopes.PROFILE));
neededScopes.add(new Scope(Scopes.EMAIL));
neededScopes.add(new Scope(Scopes.OPEN_ID));

AuthorizationRequest request = AuthorizationRequest.builder()
    .setRequestedScopes(neededScopes)
    .build();

Identity.getAuthorizationClient(this)
    .authorize(request)
    .addOnSuccessListener(result -> {
        if (result.hasResolution()) {
            PendingIntent intent = result.getPendingIntent();
            // Launch authorization flow
        } else {
            // Authorization successful
            currentAccount = result;
            // But result.toGoogleSignInAccount().getDisplayName() returns null!
        }
    })
    .addOnFailureListener(error -> {
        Log.e("Auth", "Authorization failed", error);
    });

The problem is that even with all these scopes, when I call result.toGoogleSignInAccount().getDisplayName() it always returns null.

I also tried using CredentialManager but that always shows UI dialogs, which doesn’t work for my use case since I need background sync to Google Drive.

It seems weird that after a user picks their account for authorization, the app can’t even show which account they selected. Has anyone solved this problem? I’ve been stuck on this for weeks and would really appreciate some working code examples.

Had the exact same issue a few months back and it drove me crazy. The problem is that the Authorization API is designed to be minimal and doesn’t actually fetch user profile data by default, even when you include profile scopes. You need to make a separate API call to get the display name. After getting authorization, use the People API to fetch user info. Make sure you have the People API enabled in your Google Cloud Console project. Then call people().get('people/me') with the personFields parameter set to ‘names’. The authorization gives you the token, but you still need to explicitly request the profile data through the proper API endpoint. This separation is intentional for privacy reasons - authorization for Drive access doesn’t automatically grant access to detailed profile information without an explicit API call.

I ran into this same frustration when migrating from the old Google Sign-In SDK. The issue is that toGoogleSignInAccount() is essentially a compatibility method that doesn’t populate all fields properly with the new Authorization API flow. What worked for me was accessing the authorized account directly through the AuthorizedAccount object instead of converting it. You can get basic account info using result.getAccount().name which should give you the email, then make a call to the People API v1 using people/me?personFields=names,emailAddresses to get the display name. Don’t forget to add the People API dependency to your gradle file and enable it in the console. The key insight is that the Authorization API treats profile data as a separate concern from Drive authorization, so you need two API calls - one for auth and another for profile details.

honestly this caught me off guard too when i switched over. the new auth system is kinda annoying becuase it doesnt automatically populate user details like the old signin did. you’re basically getting a bare-bones authorization token without profile info loaded. try calling GoogleSignIn.getLastSignedInAccount() after authorization - sometimes that works better than the conversion method. alternatively you might need to hit the oauth2/v2/userinfo endpoint directly with your access token to grab display name and email.