-1

I'm trying to launch with Eclipse https://developers.google.com/sheets/api/quickstart/java

and

private static Credential authorize() throws Exception {
    // load client secrets
    GoogleClientSecrets clientSecrets = 
    GoogleClientSecrets.load(JSON_FACTORY,new   
    InputStreamReader(PlusSample.class.
    getResourceAsStream("/client_secrets.json")));

gives me

*янв 22, 2018 12:47:46 AM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody: C:\Users\805268\workspace\DoubleTimeSwing
янв 22, 2018 12:47:46 AM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for owner: C:\Users\805268\workspace\DoubleTimeSwing
java.lang.NullPointerException
    at java.io.Reader.<init>(Unknown Source)
    at java.io.InputStreamReader.<init>(Unknown Source)
    at SandCourt.main33.PlusSample.authorize(PlusSample.java:72)
    at SandCourt.main33.PlusSample.main(PlusSample.java:97)*

i had used this solution way https://stackoverflow.com/a/34797777/9248765

and get more trouble:

янв 22, 2018 1:47:09 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody: C:\Users\805268\.credentials\sheets.googleapis.com-java-quickstart
янв 22, 2018 1:47:09 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for owner: C:\Users\805268\.credentials\sheets.googleapis.com-java-quickstart
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
    at com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver.getRedirectUri(LocalServerReceiver.java:118)
    at com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.authorize(AuthorizationCodeInstalledApp.java:78)
    at SandCourt.main33.Quickstart.authorize(Quickstart.java:74)

...

on this line [78] flow, new LocalServerReceiver()).authorize("user");

What am I doing wrong?

Ludov Dmitrii
  • 425
  • 5
  • 9
  • 1
    So what exactly is your question? Is it about the first exception or the second? And what in the official documentation is not working for you? Please [edit] your question to include these things, and remove the things that just add noise (the first sentence, for example, adds nothing to your question.) – Joe C Jan 21 '18 at 22:09
  • 1
    In your first exception, you use `setUserCredentials()`. This is very very bad, it has been out of action for a long time and should not be used. If you had read the official documentation you should have seen the big warning message at the top of this page: https://developers.google.com/gdata/docs/auth/clientlogin Please remove the first part of your question and then give us more details about the second part including your client_secrets.json – sorifiend Jan 21 '18 at 22:15
  • Possible duplicate of [WARNING: unable to change permissions for everybody:](https://stackoverflow.com/questions/30634827/warning-unable-to-change-permissions-for-everybody) You get a `NullPointerException` meaning your json file is probably not being loaded at all. – sorifiend Jan 21 '18 at 22:22

1 Answers1

0

I had (JRE) instead of the Java Development Kit (JDK), the #2 problem. And #1 was wrong .Json File. Carefully and precisely follow the instructions of Step 1. https://developers.google.com/sheets/api/quickstart/java#step_1_turn_on_the_api_name

Ludov Dmitrii
  • 425
  • 5
  • 9