Class User

  • TheUser class in Google Drive represents a user associated with a file and can be accessed through methods likeFile.getEditors() orFolder.getViewers().

  • Available methods for aUser include retrieving their domain (getDomain()), email address (getEmail()), name (getName()), and photo URL (getPhotoUrl()).

  • ThegetUserLoginId() method is deprecated and has been replaced bygetEmail().

User

A user associated with a file in Google Drive. Users can be accessed fromFile.getEditors(),Folder.getViewers(), and other methods.

// Log the email address of all users who have edit access to a file.constfile=DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');consteditors=file.getEditors();for(leti=0;i <editors.length;i++){Logger.log(editors[i].getEmail());}

Methods

MethodReturn typeBrief description
getDomain()String|nullGets the domain name associated with the user's account.
getEmail()String|nullGets the user's email address.
getName()String|nullGets the user's name.
getPhotoUrl()String|nullGets the URL for the user's photo.

Deprecated methods

MethodReturn typeBrief description
getUserLoginId()StringGets the user's email address.

Detailed documentation

getDomain()

Gets the domain name associated with the user's account.

// Log the domain names associated with all users who have edit access to a// file.constfile=DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');consteditors=file.getEditors();for(leti=0;i <editors.length;i++){Logger.log(editors[i].getDomain());}

Return

String|null — the domain name associated with the user's account


getEmail()

Gets the user's email address. The user's email address is only available if the user haschosen to share the address from the Google+ account settings page, or if the user belongs tothe same domain as the user running the script and the domain administrator has allowed allusers within the domain to see other users' email addresses.

// Log the email address of all users who have edit access to a file.constfile=DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');consteditors=file.getEditors();for(leti=0;i <editors.length;i++){Logger.log(editors[i].getEmail());}

Return

String|null — the user's email's address, or a blank string if the email address is not available


getName()

Gets the user's name. This method returnsnull if the user's name is not available.

// Log the names of all users who have edit access to a file.constfile=DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');consteditors=file.getEditors();for(leti=0;i <editors.length;i++){Logger.log(editors[i].getName());}

Return

String|null — the user's name, ornull if the name is not available


getPhotoUrl()

Gets the URL for the user's photo. This method returnsnull if the user's photo is notavailable.

// Log the URLs for the photos of all users who have edit access to a file.constfile=DriveApp.getFileById('1234567890abcdefghijklmnopqrstuvwxyz');consteditors=file.getEditors();for(leti=0;i <editors.length;i++){Logger.log(editors[i].getPhotoUrl());}

Return

String|null — the URL for the user's photo, ornull if the photo is not available

Deprecated methods

getUserLoginId()

Deprecated. As of June 24, 2013, replaced bygetEmail().

Gets the user's email address.

// Log the email address of the person running the script.Logger.log(Session.getActiveUser().getUserLoginId());

Return

String — The user's email's address.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.