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,
Just make sure that client_secret.json is under main/resources/ directory.
InputStream in =
DriveQuickstart.class.getResourceAsStream("/json/client_secret.json");
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.
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.
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.
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
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.