I want to send email using the code in this tutorial. https://developers.google.com/gmail/api/quickstart/java
I get an exception:
Aug 01, 2016 1:34:08 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody: C:\Users\johndoe\.credentials\gmail-java-quickstart.json
Aug 01, 2016 1:34:08 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for owner: C:\Users\johndoe\.credentials\gmail-java-quickstart.json
Exception in thread "main" java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:78)
at java.io.InputStreamReader.<init>(InputStreamReader.java:72)
at GmailQuickstart.authorize(GmailQuickstart.java:68)
at GmailQuickstart.getGmailService(GmailQuickstart.java:91)
at GmailQuickstart.main(GmailQuickstart.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
This is the code snippet where I got the exception:
public static Credential authorize() throws IOException {
// Load client secrets.
InputStream in =
GmailQuickstart.class.getResourceAsStream("/client_secret.json");
I changed the folder permissions to give full access to everyone, but that did not help. I also, changed the code to write to a folder outside of user directory and that also failed with the same exception.
I also used the full path for "in" as suggested here and that did not work.
I don't understand how to use the "grant" code snippet here & how it works.
How do I fix my problem ?