Re: Getting 'unable to set file permissions ' while trying OAuth2-cmdline-sample project

3,055 views
Skip to first unread message

Yaniv Inbar (יניב ענבר)

unread,
Oct 9, 2012, 8:22:30 AM10/9/12
to google-api-java-client
Thank you for reporting the problem!  I filed a bug report here:

-- Yaniv


On Fri, Sep 28, 2012 at 9:53 AM, Ruty <roberto.r...@gmail.com> wrote:
Same error, on windows 7 and java 1.7

Il giorno giovedì 27 settembre 2012 21:10:52 UTC+2, Duke Cvar ha scritto:
I'm getting this too.  I looked at the class that's throwing this and here's the offending chunk of code:

      // set file permissions to be only readable by user
      if (!file.setReadable(false, false) || !file.setWritable(false, false)
          || !file.setExecutable(false, false) || !file.setReadable(true)
          || !file.setWritable(true)) {
        throw new IOException("unable to set file permissions");
      } I believe, in my case, that java 6 can't change read & exe permissions on Windows 7. The following methods fail even when I run them as administrator: file.setReadable(boolean) file.setReadable(boolean, boolean) file.setExecutable(boolean) file.setExecutable(boolean, boolean) Any advise from Google or others on how to run this on Windows?

On Monday, September 10, 2012 3:49:26 AM UTC-6, Veerabhadraiah as wrote:
Hi All,

I downloaded the OAuth 2 sample code from http://code.google.com/p/google-api-java-client/source/browse?repo=samples#hg/oauth2-cmdline-sample, and created the project in eclipse. Now when i try to run the project it says 'unable to set file permissions' at  FileCredentialStore credentialStore = new FileCredentialStore(
        new File(System.getProperty("user.home"), ".credentials/oauth2.json"), JSON_FACTORY);
    // set up authorization code flow
    GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
        HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES).setCredentialStore(credentialStore)
        .build();

Has anyone got this error earlier? What is the solutions for this?

Sakthivel A

unread,
Jan 12, 2015, 6:10:36 AM1/12/15
to google-api-...@googlegroups.com
Hi @All,

             I Have the same error, with Windows xp, eclipse juno and java 1.7.

com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody:C:\Documents and Settings\Admin\.oauth-credentials

Anyone post right answer here it will help to others.

Thanks,
Sakthivel A

Anthony Moore

unread,
Jan 14, 2015, 8:01:46 PM1/14/15
to google-api-...@googlegroups.com
This is the source code in question:

// disable access by other users if O/S allows it
    if (!dataDirectory.setReadable(false, false) || !dataDirectory.setWritable(false, false)
        || !dataDirectory.setExecutable(false, false)) {
      LOGGER.warning("unable to change permissions for everybody: " + dataDirectory);
    }
In October 2012 it was changed into a warning instead of an error. Is that creating difficulty other than the diagnostic noise?

A way to stop the noisy diagnostic here would be to stop trying to execute this if block on Windows since it is known not to work.
Reply all
Reply to author
Forward
0 new messages