Google Drive API - the name must not be empty: null (But I had passed valid account name to GoogleAccountCredential)

It looks like the Drive API Client Library for Java calls into GoogleAuthUtil.getToken(), which requires the GET_ACCOUNTS permission. You need to have that permission in your manifest and request it at runtime, as appropriate.

UPDATE: With Google Drive REST v3 API, GET_ACCOUNTS permission is not required. Instead, Email permission is required. You can ask for it by calling GoogleSignInOptions.Builder.requestEmail.


I had the same problem, all permissions were granted and still I got this error.

My simple problem was, that the googleSignInAccount.getSignInAccount().getAccount() was null. This is the case, if you do NOT request the email permissions (GoogleSignInOptions.Builder.requestEmail). Seems like this account can't be created without the user email.

So make sure to add this permission to the GoogleSignInOptions...


This is because from Android 6.0 (API level 23) you need to get the Contacts permission before you invoke google endpoints.

You can see complete details here - https://developer.android.com/training/permissions/requesting.html

This is true only for Dangerous permissions and permission groups (based on how much they are related to user privacy). More details - https://developer.android.com/guide/topics/security/permissions.html#perm-groups