Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9220193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:17:27+00:00 2026-06-18T03:17:27+00:00

When using this line of code in a Google Apps Script var user =

  • 0

When using this line of code in a Google Apps Script

  var user = folders[n].getOwner().getEmail()

I get an error saying I am not authorized to perform such an action (your version may vary, I am translating from italian).

What gives? I am just retrieving an information, such as the owner of a folder.


When the script processes a folder I own, the error does not arise, the error arises when it encounters a folder not of mine. The matter is that this line of code is just for spotting folders which are not of mine, to avoid issuing method that would correctly rise an error, like setTrashed. The script looks for empty folders to delete them, but I cannot delete folders I am not the owner of of course. And yes I am into Google apps for business, does it make some difference?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:17:28+00:00Added an answer on June 18, 2026 at 3:17 am

    There isn’t any specifc warning about file.getOwner().getEmail(), but there is for Class Session.

    In limited-privilege executions (such as in response to onOpen or
    onEdit), we only return the identity of the active user if both the
    user and the script owner are part of the same domain. This is to
    protect the privacy of consumer users, who may not want their email
    address exposed.

    I have no problem with this in a consumer account.

    The following function is an excerpt from a gist I posted for a previous question. It wraps the call to .getEmail() (or getUserLoginId() if you prefer) in a try ... catch block, so it avoids errors for users crossing Apps Domains.

    function getFileInfo (file,fileType) {
      var fileInfo = {
        id: file.getId(),
        name: file.getName(), 
        size: file.getSize(),
        type: (fileType == "file") ? docTypeToText_(file.getFileType()) : "folder",
        created: file.getDateCreated(),
        description: file.getDescription(),
        owner: file.getOwner()
      }
      try {
        fileInfo.owner = file.getOwner().getEmail()//.getUserLoginId()
      } catch(e)
      {
        // Possible permission problem
        fileInfo.owner = "unknown";
      }
      return fileInfo;
    }
    

    UPDATE: Since this was first posted, something has changed. Now my consumer account encounters the aforementioned error when trying to access getOwner() for a file shared from another account. (March 3, 2013)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this line of code to get two data entries from an
I'm using this line of code to insert a value from an array into
I want to use this line of code: using (ADataContext _dc = new ADataContext(ConnectionString),
I tried using juggernaut cocoa: https://github.com/fpotter/juggernaut-cocoa Added this line to my code: JuggernautClient *client
I have a line, which is a sprite made by using this code CGPoint
I'm using this line to get the beginning time of the first day of
I'm building a UI in Google Sites using Apps Script and I am able
I'm receiving the following error on this line of code select.up().appendChild(sw); With error SCRIPT438:
I have a script that gets some JSON data from google apps scriptDB using
I am trying to get the profiles feed from my Google Apps domain using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.