quibblify
quibblify

Reputation: 395

WARNING: unable to change permissions for everybody:

When running the Java quickstart sample at https://developers.google.com/drive/web/quickstart/java?hl=hu in NetBeans, I'm receiving the error code:

Jun 04, 2015 12:12:11 AM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody:
C:\Users\Quibbles\credentials\drive-api-quickstart

What am I doing wrong?

Edit: This is the complete error message.

Jun 04, 2015 5:11:39 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for owner: C:\Users\Quibbles\.credentials\drive-api-quickstart
Exception in thread "main" java.lang.NullPointerException
    at java.io.Reader.<init>(Reader.java:78)
    at java.io.InputStreamReader.<init>(InputStreamReader.java:72)
    at DriveQuickstart.authorize(DriveQuickstart.java:64)
    at DriveQuickstart.getDriveService(DriveQuickstart.java:87)
    at DriveQuickstart.main(DriveQuickstart.java:96)
Java Result: 1

Upvotes: 31

Views: 27047

Answers (9)

sangeetha s
sangeetha s

Reputation: 1

Use Below dependencies. It will remove that warning.

    <dependency>
        <groupId>com.google.oauth-client</groupId>
        <artifactId>google-oauth-client-jetty</artifactId>
        <version>1.35.0</version>
    </dependency>
  <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>javax.mail-api</artifactId>
        <version>1.6.2</version>
    </dependency>

    
    <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.17.2</version>
    </dependency>
    <dependency>
        <groupId>com.google.apis</groupId>
        <artifactId>google-api-services-gmail</artifactId>
        <version>v1-rev110-1.25.0</version>
    </dependency>

Upvotes: 0

AshX
AshX

Reputation: 1

Was able to resolve the issue by deleting the StoredCredentials files under the token folder. I had to reauthenticate again with google the next time the program was executed.

Upvotes: 0

Eduardo Aparecido
Eduardo Aparecido

Reputation: 31

Basically if you already enabled de Drive API and created credentials.json file at Google Drive API Rest, now you need :

1 - Remove the tokens directory generated in you last execution. In this directory contains a file StoredCredential. 2 - Change de SCOPE to DriveScopes.DRIVE like sample bellow:

private static List SCOPES = Collections.singletonList(DriveScopes.DRIVE);

3 - Re run the program. It will be request that you login in your google account to give the access consent.

4 - It will be generated a new one tokens directory in your project and now with with read and write permissions at google Drive.

This work for me.

Upvotes: 3

Just make sure that client_secret.json is under main/resources/ directory.enter image description here

InputStream in =
            DriveQuickstart.class.getResourceAsStream("/json/client_secret.json");

Upvotes: 0

Dilip Mane
Dilip Mane

Reputation: 51

I was facing same issue in Eclipse. Here’s a solution:

  1. Run eclipse in admin mode

  2. Clear the directory C:/Users/<username>.credentials/calendar-java-quickstart.json

  3. Copy the .json file the bin directory, e.g. bin/main/resources/client_secret.json

You are free to run now.

Upvotes: 5

JustADev
JustADev

Reputation: 181

The actual problem is a bug in Google's API code for setPermissionsToOwnerOnly

The code was written to only work on Linux/Unix based systems and not Windows ACL based systems.

You can ignore the warning or write your own DataStore class that sets the permissions correctly for Windows.

I'm going to try to file a bug with Google on it too.

Upvotes: 18

C Deepak
C Deepak

Reputation: 1278

Had the same issue and wasted hours before realizing that "unable to change permissions for owner: C:\Users\Quibbles.credentials\drive-api-quickstart"
is just a warning.

The real issue is the null pointer here.

InputStream in =
            DriveQuickstart.class.getResourceAsStream("/client_secret.json");

This line was the issue in my case. "in" was null and hence the null pointer.

InputStream in    = new FileInputStream("<Full Path>\\client_secret.json");  

This resolved my issue.

Upvotes: 35

user1864863
user1864863

Reputation: 51

Had the same problem when running the example given in the tutorial "https://developers.google.com/drive/v2/web/quickstart/java". Followed the instruction ditto as given the in the tutorial, but kept getting this permission exception. Eventually, managed to sort it out by moving the "client_secret.json" to the "\build\classes\main\classes" folder. Also, before building the project with "gradle -q run" for the first time, delete any files in the "C:\Users\userName\.credentials" folder.

Upvotes: 0

nicordesigns
nicordesigns

Reputation: 904

I just ran into the same issue with the https://developers.google.com/google-apps/calendar/quickstart/java example. I suspect that the issue is that you are running it in Windows and the JVM that you are running it does not have Adminsitrator rights for changing the file permissions in Windows.

See Run Java application as administrator on Windows

Upvotes: 0

Related Questions